在配置action之前加上:
<global-allowed-methods>regex:.*</global-allowed-methods>
以下是struts.xml的代码:
<?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>
<package name="defalt" namespace="/" extends="struts-default">
<!--
struts2.5和sturts2.3区别,2.5必须加上
<global-allowed-methods>regex:.*</global-allowed-methods>
否则找不到路径
-->
<global-allowed-methods>regex:.*</global-allowed-methods>
<!-- 通配符配置动态action映射 -->
<action name="helloworld_*" method="{1}" class="com.structs.demo.HelloWorldAction">
<result>/result.jsp</result>
<result name="add">/{1}.jsp</result>
<result name="subtract">/{1}.jsp</result>
<result name="multiply">/{1}.jsp</result>
<result name="divide">/{1}.jsp</result>
</action>
</package>
</struts>