Struts 2.5 Action动态调用 SMI 配置
struts.xml:
其中,需要使用的坂本为Struts 2.5 DTD,<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd"> <struts> <constant name="struts.i18n.encoding" value="UTF-8"/> <constant name="struts.enable.DynamicMethodInvocation" value="true"/> <package strict-method-invocation="false" name="default" namespace="/" extends="struts-default"> <action name="user" class="com.action.UserAction"> <result name="hello">/hello.jsp</result> <result name="update">/update.jsp</result> </action> </package> </struts>
struts.enable.DynamicMethodInvocation需要设置为true打开DMI功能, package 的strict-method-invocation属性值默认为true,需要关闭改为false,否则报错提示:
HTTP Status 404 - Method update for action user is not allowed!
type Status report
message Method update for action user is not allowed!
description The requested resource is not available.
Apache Tomcat/7.0.78
参考文档:http://struts.apache.org/docs/action-configuration.html