Struts2老问题:There is no Action mapped for namespace / and action name logon

蜡笔1小新 2015-03-18 04:19:44
烦死了,帮忙看看吧各位。[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/10.gif]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
"http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<package name="default" extends="struts-default" namespace="/">
<action name="logon" class="com.action.LoginAction" method="logon">
<result name="input">/index.jsp</result>
<result name="success" type="redirect">/success.jsp</result>
<result name="error">/failed.jsp</result>
</action>
</package>
</struts>
...全文
386 38 打赏 收藏 转发到动态 举报
写回复
用AI写文章
38 条回复
切换为时间正序
请发表友善的回复…
发表回复
蜡笔1小新 2015-03-19
  • 打赏
  • 举报
回复
引用 34 楼 u010559460 的回复:
[quote=引用 32 楼 u012252681 的回复:] [quote=引用 30 楼 u013762572 的回复:] [quote=引用 28 楼 u010559460 的回复:] 我大概猜到你错哪里了, 你的applcationContext.xml文件没有, .首先在src下添加 applcationContext.xml 然后 在里面添加两个Bean,(userDto,LoginAction) 把userDto注入到LoginAction 在把struts.xml中class="com.action.LoginAction" 改成class="loginAction", 最后看下你 struts-spring.jar添加了没
如果我只用struts2,那会怎么样??[/quote]对啊,我都还没用到spring,这应该没影响的[/quote] --------------------------------------------------------------------------------------------------------------------------- 你的web.xml文件里配置了Spring容器的监听 <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:applicationContext*.xml</param-value> </context-param> 把它去掉,再试试,看看启动时候有又有报错, 如果没有报错, 用frefox看下提交时候的地址 [/quote]地址没问题,去掉那段启动肯定报错了呀
引用 35 楼 lkt19911025 的回复:
<display-name>test1_ssh</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:applicationContext*.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> 你没用spring 要这个配置干什么
我接下来肯定要用到spring啊,不过现在还没用到的,只是struts2
蜡笔1小新 2015-03-19
  • 打赏
  • 举报
回复
引用 34 楼 u010559460 的回复:
[quote=引用 32 楼 u012252681 的回复:] [quote=引用 30 楼 u013762572 的回复:] [quote=引用 28 楼 u010559460 的回复:] 我大概猜到你错哪里了, 你的applcationContext.xml文件没有, .首先在src下添加 applcationContext.xml 然后 在里面添加两个Bean,(userDto,LoginAction) 把userDto注入到LoginAction 在把struts.xml中class="com.action.LoginAction" 改成class="loginAction", 最后看下你 struts-spring.jar添加了没
如果我只用struts2,那会怎么样??[/quote]对啊,我都还没用到spring,这应该没影响的[/quote] --------------------------------------------------------------------------------------------------------------------------- 你的web.xml文件里配置了Spring容器的监听 <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:applicationContext*.xml</param-value> </context-param> 把它去掉,再试试,看看启动时候有又有报错, 如果没有报错, 用frefox看下提交时候的地址 [/quote]地址没问题,去掉那段启动肯定报错了呀
leeKitty 2015-03-19
  • 打赏
  • 举报
回复
<display-name>test1_ssh</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:applicationContext*.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> 你没用spring 要这个配置干什么
踏 浪 2015-03-19
  • 打赏
  • 举报
回复
引用 32 楼 u012252681 的回复:
[quote=引用 30 楼 u013762572 的回复:] [quote=引用 28 楼 u010559460 的回复:] 我大概猜到你错哪里了, 你的applcationContext.xml文件没有, .首先在src下添加 applcationContext.xml 然后 在里面添加两个Bean,(userDto,LoginAction) 把userDto注入到LoginAction 在把struts.xml中class="com.action.LoginAction" 改成class="loginAction", 最后看下你 struts-spring.jar添加了没
如果我只用struts2,那会怎么样??[/quote]对啊,我都还没用到spring,这应该没影响的[/quote] --------------------------------------------------------------------------------------------------------------------------- 你的web.xml文件里配置了Spring容器的监听 <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:applicationContext*.xml</param-value> </context-param> 把它去掉,再试试,看看启动时候有又有报错, 如果没有报错, 用frefox看下提交时候的地址
蜡笔1小新 2015-03-19
  • 打赏
  • 举报
回复
引用 29 楼 u013762572 的回复:
先在HTML中加个这
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>

然后用个base标签。。。<base href=<%=basePath%>/>
试试 ,不能的 再问我吧
空指针
蜡笔1小新 2015-03-19
  • 打赏
  • 举报
回复
引用 30 楼 u013762572 的回复:
[quote=引用 28 楼 u010559460 的回复:] 我大概猜到你错哪里了, 你的applcationContext.xml文件没有, .首先在src下添加 applcationContext.xml 然后 在里面添加两个Bean,(userDto,LoginAction) 把userDto注入到LoginAction 在把struts.xml中class="com.action.LoginAction" 改成class="loginAction", 最后看下你 struts-spring.jar添加了没
如果我只用struts2,那会怎么样??[/quote]对啊,我都还没用到spring,这应该没影响的
蜡笔1小新 2015-03-19
  • 打赏
  • 举报
回复
引用 26 楼 a327369238 的回复:
我把你代码复制下来在我这运行成功了 你重新新建一个工程在里面运行下看看?
那应该是jar包的问题吧
蜡笔1小新 2015-03-19
  • 打赏
  • 举报
回复
问题已解决,好像是eclipse问题,这个eclipse是之前weblogic专用的,换个eclipse就可以了,具体为什么我也搞不清楚
microhex 2015-03-18
  • 打赏
  • 举报
回复
引用 28 楼 u010559460 的回复:
我大概猜到你错哪里了, 你的applcationContext.xml文件没有, .首先在src下添加 applcationContext.xml 然后 在里面添加两个Bean,(userDto,LoginAction) 把userDto注入到LoginAction 在把struts.xml中class="com.action.LoginAction" 改成class="loginAction", 最后看下你 struts-spring.jar添加了没
如果我只用struts2,那会怎么样??
microhex 2015-03-18
  • 打赏
  • 举报
回复
先在HTML中加个这 <% String path = request.getContextPath(); String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort() + path + "/"; %> 然后用个base标签。。。<base href=<%=basePath%>/> 试试 ,不能的 再问我吧
踏 浪 2015-03-18
  • 打赏
  • 举报
回复
我大概猜到你错哪里了, 你的applcationContext.xml文件没有, .首先在src下添加 applcationContext.xml 然后 在里面添加两个Bean,(userDto,LoginAction) 把userDto注入到LoginAction 在把struts.xml中class="com.action.LoginAction" 改成class="loginAction", 最后看下你 struts-spring.jar添加了没
踏 浪 2015-03-18
  • 打赏
  • 举报
回复
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:applicationContext*.xml</param-value> </context-param> 把* 去掉,! <input type="submit" name="logon" value="登录"/> name属性可以不要. 请求tomcat有没有报错!
a327369238 2015-03-18
  • 打赏
  • 举报
回复
我把你代码复制下来在我这运行成功了 你重新新建一个工程在里面运行下看看?
蜡笔1小新 2015-03-18
  • 打赏
  • 举报
回复
引用 23 楼 a327369238 的回复:
我也感觉是缓存之类的问题,你重启下试试 还有,那个form里面的action最好直接写action类名不要加后缀,写了好像有警告
应该不是缓存,我试了一下午了,浏览器也换了,都没用的
leeKitty 2015-03-18
  • 打赏
  • 举报
回复
引用 21 楼 lkt19911025 的回复:
把 struts.xml 中的 namespace="/" 去掉
而且 在action文件里 重载方法public String execute() return SUCCESS; 大写 你试试
a327369238 2015-03-18
  • 打赏
  • 举报
回复
我也感觉是缓存之类的问题,你重启下试试 还有,那个form里面的action最好直接写action类名不要加后缀,写了好像有警告
蜡笔1小新 2015-03-18
  • 打赏
  • 举报
回复
引用 21 楼 lkt19911025 的回复:
把 struts.xml 中的 namespace="/" 去掉
我本来就没写,默认就是这个,看到网上说要写才加上的
leeKitty 2015-03-18
  • 打赏
  • 举报
回复
把 struts.xml 中的 namespace="/" 去掉
蜡笔1小新 2015-03-18
  • 打赏
  • 举报
回复
引用 19 楼 lwb314 的回复:
没看出来有什么问题,你按照楼上传送门的做法也不好使吗?,你提交完以后浏览器的的URL发一下
都试过了,url:http://localhost:8080/test1_ssh/logon.action
  • 打赏
  • 举报
回复
没看出来有什么问题,你按照楼上传送门的做法也不好使吗?,你提交完以后浏览器的的URL发一下
加载更多回复(18)

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧