项目名称为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,一头茫然~~ 谢谢~

解决方案 »

  1.   

    这是struts2.0么!
    还没接触 期待楼下精彩解答。。
      

  2.   

    问题补充:
    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
      

  3.   

    那个Action的name=“login.action”有问题,提交的时候不是有login.action,这里就不用.action了
      

  4.   

    com.ybzy.cn.LoginAction 不是Action类吧,
      

  5.   

    <action name="login.action" class="com.ybzy.cn.LoginAction"> 
    这句有问题,这里定义名字不需要用login.action,只是取个名字,不需要加扩展,就写成login就可以了。页面上调用com.ybzy.cn.LoginAction中的execute()方法时就直接action="login.action",如果需要转到com.ybzy.cn.LoginAction中的其他方法,就写成action="login!方法名.action"
      

  6.   

    <action name="login.action" class="com.ybzy.cn.LoginAction"> 
    改为
    <action name="login" class="com.ybzy.cn.LoginAction">