首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

运用通配符定义action

2012-09-09 
使用通配符定义actionpackage nameitcast namespace/test extendsstruts-default action name

使用通配符定义action
<package name="itcast" namespace="/test" extends="struts-default">
<action name="helloworld_*"
<!--helloworld_* 其中_*表示匹配后面的{1}中的参数 -->
method="{1}">
<result name="success">/WEB-INF/page/hello.jsp</result>
</action>
</package>
public class HelloWorldAction{
private String message;
....
public String execute() throws Exception{
this.message = "我的第一个struts2应用";
return "success";
}

public String other() throws Exception{
this.message = "第二个方法";
return "success";
}
}

要访问other()方法,可以通过这样的URL访问:/test/helloworld_other.action

热点排行