使用struts2框架遇到的问题

  1. 今天使用struts2写项目,配置好之后做了一个简单的测试,看jsp中的表单是否能够正常跳转到对应的action,但是刚开始运行就报错。
    • 错误信息如下:
WARNING: No configuration found for the specified action: 'loginAction' in namespace: '/userAction'. Form action defaulting to 'action' attribute's literal value.
九月 24, 2017 3:42:53 下午 org.apache.struts2.components.ServletUrlRenderer warn
WARNING: No configuration found for the specified action: 'loginAction' in namespace: '/userAction'. Form action defaulting to 'action' attribute's literal value.
九月 24, 2017 3:42:53 下午 org.apache.struts2.components.ServletUrlRenderer warn
WARNING: No configuration found for the specified action: 'loginAction' in namespace: '/userAction'. Form action defaulting to 'action' attribute's literal value.
九月 24, 2017 3:42:54 下午 org.apache.struts2.components.ServletUrlRenderer warn
WARNING: No configuration found for the specified action: 'loginAction' in namespace: '/userAction'. Form action defaulting to 'action' attribute's literal value.
九月 24, 2017 3:42:54 下午 org.apache.struts2.components.ServletUrlRenderer warn
WARNING: No configuration found for the specified action: 'loginAction' in namespace: '/userAction'. Form action defaulting to 'action' attribute's literal value.
九月 24, 2017 3:42:56 下午 org.apache.struts2.dispatcher.Dispatcher warn
WARNING: Could not find action or result: /loginAction
There is no Action mapped for namespace [/] and action name [loginAction] associated with context path []. - [unknown location]
    at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
    at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)

说是找不到对应的action,看了一下struts.xml中的配置信息并没有出错,
在网上搜索了一下说是使用struts的tag时需要在表单中注明namespace属性,用以指定action对应的namespace(这里的namespace与struts.xml中package的namespace一致)
2. 但是解决了上边的namespace之后还是无法找到对应的action:又检查了一下,发现错把struts.xml文件放到了web-INF下,之后把struts.xml文件移动到src目录下后上边的warning信息以及找不到action的信息消除了。
3. 随后再次运行,发现提交表单之后出现了404错误。真的是无语了。。。再次检查,发现之前调试1中出现的问题的时候把web.xml中的struts2的核心过滤器请求改成了*.action和之后的 ❉.jsp,再次修改,把过滤内容修改为回原来的过滤所有(/❉)之后问题解决。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值