项目名称为Server
2个Jsp页面 login.jsp reuslt.jsp
1个java类 名字 com.ybzy.cn.LoginAction
struts.xml
<?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>
<package name="Sever" extends="struts-default">
<action name="login.action" class="com.ybzy.cn.LoginAction">
<result name="success">/reuslt.jsp</result></action></package></struts>
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>
</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>
相关jar 也都导入了到WEB-INF 下的lib 中
问题:login.jsp能运行,点击提交表单运行后出现404错误~~
刚接触struts,一头茫然~~ 谢谢~
2个Jsp页面 login.jsp reuslt.jsp
1个java类 名字 com.ybzy.cn.LoginAction
struts.xml
<?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>
<package name="Sever" extends="struts-default">
<action name="login.action" class="com.ybzy.cn.LoginAction">
<result name="success">/reuslt.jsp</result></action></package></struts>
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>
</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>
相关jar 也都导入了到WEB-INF 下的lib 中
问题:login.jsp能运行,点击提交表单运行后出现404错误~~
刚接触struts,一头茫然~~ 谢谢~
还没接触 期待楼下精彩解答。。
HTTP Status 404 - There is no Action mapped for namespace / and action name login.--------------------------------------------------------------------------------type Status reportmessage There is no Action mapped for namespace / and action name login.description The requested resource (There is no Action mapped for namespace / and action name login.) is not available.
--------------------------------------------------------------------------------Apache Tomcat/6.0.20
这句有问题,这里定义名字不需要用login.action,只是取个名字,不需要加扩展,就写成login就可以了。页面上调用com.ybzy.cn.LoginAction中的execute()方法时就直接action="login.action",如果需要转到com.ybzy.cn.LoginAction中的其他方法,就写成action="login!方法名.action"
改为
<action name="login" class="com.ybzy.cn.LoginAction">