struts2找不到action映射
运行时出现这个问题:
HTTP Status 404 - There is no Action mapped for action name userlogin.
--------------------------------------------
type Status report
messageThere is no Action mapped for action name userlogin.
descriptionThe requested resource (There is no Action mapped for action name userlogin.) is not available.
struts.xml 放在WIB-INF下了
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory"/>
<package name="strutsspring" namespace="/user" extends="struts-default">
<action name="userlogin" class="UserLoginAction">
<result name="success">/showpage/index.jsp</result>
<result name="input">/showpage/login.jsp</result>
</action>
</package>
</struts>
ApplicationContext.xml配置
<!-- action injection -->
<bean id="UserLoginAction" class="com.bjoraclewdp.ticket.controller.UserLoginAction" scope="prototype">
<property name="userService" ref="UserService"></property>
</bean>
JSP文件
<s:form action="/user/userlogin.action" theme="simple">
<p>用户名: <input type="text" id="username" name="username" value="${param.username}" style=" background:none;border:none;width:160px;height:27px;border:solid 1px #499EB3; line-height:27px;padding-left:5px;"/></p>
<span id="usernameInfo">
<s:fielderror>
<s:param>usernameInfo</s:param>
</s:fielderror>
</span>
<p>密 码: <input id="password" name="password" type="password" style=" background:none;border:none;width:160px;height:27px;border:solid 1px #499EB3; line-height:27px;padding-left:5px;"/></p>
<span id="passwordInfo">
<s:fielderror>
<s:param>passwordInfo</s:param>
</s:fielderror>
</span>
<p><input name="" type="submit" value="登 录" onclick="text()" style="background:none;border:none;width:78px;height:30px; background:url(../images/button.jpg) no-repeat;color:#FFFFFF;font-size:14px;margin-left:55px;"/><input name="" type="button" value="取 消" style="background:none;border:none;width:78px;height:30px; background:url(../images/button.jpg) no-repeat;color:#FFFFFF;font-size:14px;margin-left:5px;"/></p>
</s:form>
1:烦大家帮忙看看 是哪里错误 找半天都找不到?
2:部署出现这个问题 应该怎么解决
警告: No configuration found for the specified action: '/user/userlogin.action' in namespace: '/showpage'. Form action defaulting to 'action' attribute's literal value.
警告: No configuration found for the specified action: '/user/userlogin.action' in namespace: '/showpage'. Form action defaulting to 'action' attribute's literal value.
警告: Could not find action or result
[解决办法]
No configuration found for the specified action: '/user/userlogin.action' in namespace: '/showpage'. Form action defaulting to 'action' attribute's literal value.
根据这个消息来看,应该是你的当前页面在/showpage命名空间内,可能是你访问/showpage之后调整到当前页面的,之后你再当前页面想要跳转到/user空间内,所以目前访问就变成了/showpage/user 即将在showpage空间内找user 当然是不存在的。 这个你可以看看地址栏,应该就是/showpage/user 如果是内嵌页面你可以右键属性看到地址。
解决办法一: 如果你的/user空间就只有这个地方用,或者就是再/showpage/空间下使用,那么更改 struts.xml中的<package name="strutsspring" namespace="/user" extends="struts-default">
<action name="userlogin" class="UserLoginAction">
将namespace改成 /showpage/user 。 这种方法要注意,如果你其他地方也有访问user命名空间,而不是在/showpage空间下,则其他项目访问将出问题。。慎用!!!
解决办法二: 将form的acton改成绝对路径 即:<form action="<%=basePath%>user/userlogin.action"
或者你直接写死: <form action="http://127.0.0.1:7001/test/user/userlogin.action" 这个路径只是举个例子。你可以改成你自己的真实路径 http://ip:端口/工程名/
不懂的再问。。。。
[解决办法]
也可以放在SRC下面,namespace="" 可以直接访问
[解决办法]
配置文件放哪不是问题,问题是你的配置文件是否配好了。
参考下:
http://download.csdn.net/detail/accpzar/4431710
[解决办法]
struts.xml 放在SRC 下面 ,namespace=""