标签:
众所周知,默认条件下,在浏览器输入indexAction!execute.action,便会执行indexAction类里的execute方法,这样虽然方便,但可能带来安全隐患,通过url可以执行Action中的任意方法。
<constant name="strutsenableDynamicMethodInvocation" value="false"/>
<action name="empAction_register" class="com.syaccp.erp.action.emp.EmpAction" method="register"> <result name="success">/WEB-INF/jsp/basic/emp_list.jsp</result> <result name="input_edit">/WEB-INF/jsp/basic/emp_edit.jsp</result> <result name="input_add">/WEB-INF/jsp/basic/emp_add.jsp</result> <result name="reload" type="redirect">empAction.action</result> </action>
<action name="empAction" class="com.syaccp.erp.action.emp.EmpAction"> <result name="success">/WEB-INF/jsp/basic/emp_list.jsp</result> <result name="reload" type="redirect">empAction.action</result> </action> <action name="empAction_register" class="com.syaccp.erp.action.emp.EmpAction" method="register"> <result name="success">/WEB-INF/jsp/basic/emp_register.jsp</result> </action> <action name="empAction_login" class="com.syaccp.erp.action.emp.EmpAction" method="login"> <result name="success">/WEB-INF/jsp/basic/emp_login.jsp</result> </action>
<action name="empAction_*" class="com.syaccp.erp.action.emp.EmpAction" method="{1}"> <result name="success">/WEB-INF/jsp/basic/emp_{1}.jsp</result> </action>
<package name="default" namespace="/emp" extends="struts-default"> <default-action-ref name="defaultAction"></default-action-ref> <action name="defaultAction"> <result>/error.jsp</result> </action> </package>
2、在根目录下配置默认Action,不用填写namespace属性
<package name="default" extends="struts-default"> <default-action-ref name="defaultAction"></default-action-ref> <action name="defaultAction"> <result>/error.jsp</result> </action> </package>
Struts2理解--动态方法和method属性及通配符_默认Action
标签:
原文地址:http://www.cnblogs.com/lr393993507/p/5438023.html