分析:Struts2在2.5版本后添加strict-method-invocation(严格方法访问),默认为true,不能使用动态方法调用功能,故需设为false
struts.xml设置如下:
1 <package name="p1" extends="struts-default" namespace="/"strict-method-invocation="false"> 2 3 <!--配置全局的结果视图--> 4 <global-results> 5 <result name="login" type="redirect">/login.jsp</result> 6 </global-results> 7 8 <!--配置jsp页面的访问规则--> 9 <action name="page_*_*"> 10 <!--1:第一个*,2:第二个*--> 11 <result name="success">/WEB-INF/pages/{1}/{2}.jsp</result> 12 </action> 13 14 <!--用户模块--> 15 <action name="userAction_*" class="com.gyf.bos.web.action.UserAction" method="{1}"> 16 <result name="home">/WEB-INF/pages/common/index.jsp</result> 17 <result name="loginfailure">/login.jsp</result> 18 </action> 19 </package>
推荐设置:namespace="/"
提示:因为SSH项目已经有很多年头了,使用时要考虑到版本问题。