Could not find action or result: /Struts2_Demo01

J2EE 码拜 9年前 (2015-04-11) 1257次浏览 0个评论

警告: Could not find action or result: /Struts2_Demo01/
There is no Action mapped for namespace [/] and action name [] associated with context path [/Struts2_Demo01]. – [unknown location]
at
 

配置struts2的时候出现这个错误,一直解决不了!求大神指点

Could not find action or result: /Struts2_Demo01
这个struts.xml的内容

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
	"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
	"http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>

	<package name="default" namespace="/" extends="struts-default">

		<action name="login" class="com.jacksen.struts2Demo01.UserAction">
			<result>/userlogin.jsp</result>

		</action>
		<action name="check" class="com.jacksen.struts2Demo01.UserAction" method="execute">
			<result name="success">/success.jsp</result>
			<result name="fail">/fail.jsp</result>
		</action>
	</package>


	<!-- Add packages here -->

</struts>
Could not find action or result: /Struts2_Demo01
web.xml

<?xml version="1.0" encoding="UTF-8"?>  
<web-app version="3.0"   
    xmlns="http://java.sun.com/xml/ns/javaee"   
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   
    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> 
	<display-name>Struts2Demo</display-name>

	<filter>
		<filter-name>struts2</filter-name>
		<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>

</web-app>
Could not find action or result: /Struts2_Demo01
url 是 什么?
Could not find action or result: /Struts2_Demo01
http://localhost/Struts2_Demo01/login.action
Could not find action or result: /Struts2_Demo01
问题解决了。我的action类忘了继承【ActionSupport】这个类了。
唉,真是粗心大意。

加上了之后,在地址栏中输入http://localhost/Struts2_Demo01/login.action,就没有错误了。
但是如果在【web.xml】中配置【<welcome-file>】的时候貌似不能写某一个action,我就是在这里边写了login.action,
虽然输入上边那个url正确了,但是如果让eclipse自动弹出网页的时候还是会报错。
所以,把【<welcome-file>】改了就对了。

Could not find action or result: /Struts2_Demo01
20分
引用 5 楼 crazy1235 的回复:

问题解决了。我的action类忘了继承【ActionSupport】这个类了。
唉,真是粗心大意。

加上了之后,在地址栏中输入http://localhost/Struts2_Demo01/login.action,就没有错误了。
但是如果在【web.xml】中配置【<welcome-file>】的时候貌似不能写某一个action,我就是在这里边写了login.action,
虽然输入上边那个url正确了,但是如果让eclipse自动弹出网页的时候还是会报错。
所以,把【<welcome-file>】改了就对了。

看看这个

Could not find action or result: /Struts2_Demo01
引用 6 楼 rui888 的回复:
Quote: 引用 5 楼 crazy1235 的回复:

问题解决了。我的action类忘了继承【ActionSupport】这个类了。
唉,真是粗心大意。

加上了之后,在地址栏中输入http://localhost/Struts2_Demo01/login.action,就没有错误了。
但是如果在【web.xml】中配置【<welcome-file>】的时候貌似不能写某一个action,我就是在这里边写了login.action,
虽然输入上边那个url正确了,但是如果让eclipse自动弹出网页的时候还是会报错。
所以,把【<welcome-file>】改了就对了。

看看这个

多谢!

Could not find action or result: /Struts2_Demo01
我配置的时候 action没有继承ACctionSupport能运行啊,能访问action
structs。xml:
 <constant name=”struts.enable.DynamicMethodInvocation” value=”true” />
    <constant name=”struts.devMode” value=”true” />

JSP:
action=” actionname!method.action”就可以直接访问了


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明Could not find action or result: /Struts2_Demo01
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!