是不是要加这个
<struts>
<include file="struts-default.xml" />
<package name="sunyang" extends="struts-default" namespace="/sunyang">
<action name="loginUser" class="sunyang.UserAction">
<result name="success">/jsp/success.jsp </result>
<result name="error">/jsp/error.jsp </result>
</action>
</package>
</struts>
<struts>
<include file="struts-default.xml" />
<package name="sunyang" extends="struts-default" namespace="/sunyang">
<action name="loginUser" class="sunyang.UserAction">
<result name="success">/jsp/success.jsp </result>
<result name="error">/jsp/error.jsp </result>
</action>
</package>
</struts>
哈哈,struts2有个有意思的地方,如果找不到ActionMapping,它就不会认为用户请求是Action,并且请求是以/Struts开头(楼主伟大,都符合了),会自动查找在web.xml文件中配置的packages初始化参数: <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.FilterDispatcher </filter-class> <init-param> <param-name>packages</param-name> <param-value>com.lizanhong.action</param-value> </init-param> </filter>而你并没有配置packages,所以它说找不到资源。所以你的根本原因还是没找到Action,建议像3楼那样写,不然在.action页面中再打开另一个action你就会郁闷了
我xml中加入了package的引用,但还是出现同样的警告。
这是我的web.xml<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
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_2_5.xsd"><filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
<init-param>
<param-name>packages</param-name> <param-value>com.lizanhong.action</param-value> </init-param>
</filter> <filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping><listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</web-app>
刚才用2楼的方法用了一下,eclipse控制器里的警告没了,但是为什么页面跳转时还是出错
页面报错的是
type Status reportmessage /Struts2/jsp/loginUserdescription The requested resource (/Struts2/jsp/loginUser) is not available.
我明明设的namespace里的路径是/sunyang为什么页面找的还是jsp目录下呢??
警告: No configuration found for the specified action: '../sunyang/loginUser' in namespace: '/sunyang'. Form action defaulting to 'action' attribute's literal value.
2008-12-23 15:14:34 org.apache.struts2.components.Form evaluateExtraParamsServletRequest
警告: No configuration found for the specified action: '../sunyang/loginUser' in namespace: '/sunyang'. Form action defaulting to 'action' attribute's literal value.jsp页面的:
<s:form action="../sunyang/loginUser" namespace="/sunyang">
其他用不着那么麻烦
或者<form action= "sunyang/loginUser">