struts2找不到action,There is no Action mapped for action name
写的一个struts的小程序,跳转action时出现ThereisnoActionmappedforactionnamelogin.求大神帮看一下,代码如下struts....
写的一个struts的小程序,跳转action时出现There is no Action mapped for action name login.
求大神帮看一下,代码如下
struts.xml:
<struts>
<constant name="struts.objectFactory" value="spring"/>
<constant name="struts.objectFactory.spring.autoWire" value="true"/>
<package name="user" namespace="/user" extends="default">
<action name="login" class="/user/login"> </action>
</package>
</struts>
web.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:applicationContext-dao.xml
classpath:applicationContext-action.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter>
<filter-name>struts-cleanup</filter-name>
<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>
<filter-mapping>
<filter-name>struts-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>/login.jsp</welcome-file>
</welcome-file-list>
login.jsp
<form action="/EduSys/user/login.action" method="post"></form>
applicationContest-action.xml
<bean name="/user/login" class="action.LoginAction" scope="request"></bean> 展开
求大神帮看一下,代码如下
struts.xml:
<struts>
<constant name="struts.objectFactory" value="spring"/>
<constant name="struts.objectFactory.spring.autoWire" value="true"/>
<package name="user" namespace="/user" extends="default">
<action name="login" class="/user/login"> </action>
</package>
</struts>
web.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:applicationContext-dao.xml
classpath:applicationContext-action.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter>
<filter-name>struts-cleanup</filter-name>
<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>
<filter-mapping>
<filter-name>struts-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>/login.jsp</welcome-file>
</welcome-file-list>
login.jsp
<form action="/EduSys/user/login.action" method="post"></form>
applicationContest-action.xml
<bean name="/user/login" class="action.LoginAction" scope="request"></bean> 展开
1个回答
展开全部
配置错了。应该是下面这样:
<struts>
<constant name="struts.objectFactory" value="spring"/>
<constant name="struts.objectFactory.spring.autoWire" value="true"/>
<package name="user" namespace="/user" extends="default">
<a<action name="login" class="loginAction"></action>
</package>
</struts>
<bean id="loginAction" class="action.LoginAction" scope="request"></bean>
<struts>
<constant name="struts.objectFactory" value="spring"/>
<constant name="struts.objectFactory.spring.autoWire" value="true"/>
<package name="user" namespace="/user" extends="default">
<a<action name="login" class="loginAction"></action>
</package>
</struts>
<bean id="loginAction" class="action.LoginAction" scope="request"></bean>
更多追问追答
追问
不行啊,的id不是应该可以自定义的么
追答
我不知道你请求的URL怎么写的,但是最好符合/user/login.action这种格式。struts2默认不支持不带请求后缀的Action。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询