web.xml的分发器代码:
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
struts.xml代码:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="hello" extends="struts-default">
<action name="hello" class="action.HelloAction" method="execute">
<result name="success">/index.jsp</result>
</action>
</package>
</struts>
常用的常量配置
<struts>
<constant name="struts.i18n.encoding" value="UTF-8"/>
<constant name="struts.action.extension" value="action,do,"></constant>
<constant name="struts.configuration.xml.reload" value="true"/>
<constant name="struts.enable.DynamicMethodInvocation" value="true"/>
<constant name="struts.multipart.maxSize" value="31457280"/>
</struts>