struts2.5配置文件中配置method不生效
struts2吧
全部回复
仅看楼主
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
level 3
楼主解决这个问题了吗
2017年08月19日 09点08分 2
这个问题折磨我好几天了,看了struts2.5的官方文档,无奈英语太差。
2017年08月19日 09点08分
回复 阳光卢梭 :没有哎,无奈我也只能用2.3来学习了
2017年08月20日 07点08分
回复
鬼爵灬宇少
:我也是 无奈之下,下了个2.3。。
2017年08月20日 12点08分
回复 阳光卢梭 :先用2.3看着吧,基础层次都差不多
2017年08月21日 08点08分
1