level 2
星月辰河丶
楼主
导入2.5的包,在配置文件struts.xml中配置action的method为指定方法名,详细如下
<?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="hello" namespace="/hello" extends="struts-default">
<action name="HelloAction" class="com.wzy.struts.test.HelloAction" method="hello">
<result name="success">/hello.jsp</result>
</action>
</package>
</struts>
但是执行后页面提示404
Type Status Report
Message Wrong method was defined as an action method: index
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
大意就是说index方法没定义,那么问题来了 我命名指定了hello方法啊。还有如果不指定method我记得应该默认找execute方法的吧,为啥这里冒出了这么个index方法呢?百思不得其解啊
如果我把HelloAction中的hello方法名改成index,就可以成功执行。
还有我把导入的包换成2.3版本的,上面一样的配置文件也可以成功。
2.5版本是否还需要配置其他地方?与2.3在解析该配置文件的时候有什么不同的地方吗?求赐教,刚开始学习struts2
2017年07月22日 12点07分
1
<?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="hello" namespace="/hello" extends="struts-default">
<action name="HelloAction" class="com.wzy.struts.test.HelloAction" method="hello">
<result name="success">/hello.jsp</result>
</action>
</package>
</struts>
但是执行后页面提示404
Type Status Report
Message Wrong method was defined as an action method: index
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
大意就是说index方法没定义,那么问题来了 我命名指定了hello方法啊。还有如果不指定method我记得应该默认找execute方法的吧,为啥这里冒出了这么个index方法呢?百思不得其解啊
如果我把HelloAction中的hello方法名改成index,就可以成功执行。
还有我把导入的包换成2.3版本的,上面一样的配置文件也可以成功。
2.5版本是否还需要配置其他地方?与2.3在解析该配置文件的时候有什么不同的地方吗?求赐教,刚开始学习struts2