开发工具:myEclipe+tomcat6.0.
目录:d:\tomcat6\webapps\SystemBBS\
下面有文件src,包com.bbs.action 类LoginAction.java
还有文件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/dt ds/struts-2.0.dtd">  <struts> 
    <package name="struts2" extends="struts-default"> 
      <action name="login" class="com.bbs.action.LoginAction"> 
          <result name="success">/success.jsp </result> 
          <result name="failure">/failure.jsp </result> 
      </action>  
    </package>  
</struts> 
d:\tomcat6\webapps\SystemBBS\rootbbs下面存放web页面,
login.jsp内容
<body> 
    <form action="login.action" method="post"> 
    username: <input type="text" name="username"/> <br> 
    password: <input type="text" name="password"/> <br> 
    <input type="submit" value="submit"/> 
</body> 其下的WEB-INF:web.xml 内容
<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="2.5"  
xmlns="http://java.sun.com/xml/ns/j2ee"  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee  
http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"> 
<display-name>Struts Blank </display-name>  
    <!--定义Struts2的FilterDispatcher的Filter-->  
    <filter>  
        <!--定义核心Filter的名字-->  
          <filter-name>struts2 </filter-name>  
        <!--定义核心Filter的实现类-->  
          <filter-class>org.apache.struts2.dispatcher.FilterDispatcher </filter-class>  
    </filter>  
    <!--FilterDispatcher用来初始化Struts2并且处理所有的Web请求-->  
    <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> struts的jar文件已经导入在lib目录下,但是运行login.jsp
总是提示:HTTP Status 404 - /SystemBBS/rootbbs/login.action我的web.xml和struts.xml都配置了,怎么还是这种错误。

解决方案 »

  1.   


    我的web.xml里边是这样配置的
    <listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListener
    </listener-class>
    </listener>
    <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/applicationContext.xml</param-value>
     </context-param> <filter> <filter-name>struts-cleanup</filter-name>
    <filter-class>
    org.apache.struts2.dispatcher.ActionContextCleanUp
    </filter-class>
    </filter> <filter>
    <filter-name>struts2</filter-name>
    <filter-class>
    org.apache.struts2.dispatcher.FilterDispatcher
    </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>希望对你有帮助!
      

  2.   


    如果没用spring 那个applicationContext.xml 的配置可以去掉
      

  3.   

    /SystemBBS/rootbbs/login.action 
    这个访问的路径不对所以找不到,才会报出404错误
    如果你这么访问,他会去你的struts2的/rootbbs命名空间下查找login.action
    而你的struts2的配置文件里并没有设置/rootbbs这个命名空间
    你可以将<package name="struts2" extends="struts-default"> 
    改成<package name="struts2" namespace="/rootbbs" extends="struts-default"> 
    试一下
      

  4.   

      <filter-mapping>  
                    <filter-name>struts2 </filter-name>  
                    <url-pattern>/* </url-pattern>  
          </filter-mapping>  你都过滤了所有的url所以你用 login.jsp看不到页面 你可以改成<url-pattern>*.action</url-pattern>  
      

  5.   

    <form action="login.action" method="post">
    改为
    <form action="/SystemBBS/rootbbs/login.action" method="post">
    试试
      

  6.   

    还有你的success.jsp确实是不是在/SystemBBS的目录下
      

  7.   

     <welcome-file-list> 
        <welcome-file>index.jsp </welcome-file> 
      </welcome-file-list> 你把index.jsp改成login.jsp,保存重新启动就OK哦
      

  8.   

    还有就是
    HTTP Status 404 - /SystemBBS/rootbbs/login.action 提示是在rootbbs目录下找不到login.action
    你把
     <form action="login.action" method="post"> 
    改成
     <form action="/login.action" method="post"> 
    试一试。
      

  9.   

    我的jsp文件在SystemBBS\rootbbs下面
    login.jsp
    success.jsp
    failure.jspLoginAction.java在SystemBBS/src目录下面 com.bbs.action上面大家说的办法都试过,还是那个错误提示!
      

  10.   

    首先谢谢!按照你得做法,提示HTTP Status 404 - /login.action
      

  11.   

    弱弱的问一句, 这是struts2吗?
      

  12.   

    过滤器 url改成*.action, 然后form表单里 加个绝对路径试试 <%=request.getContextPath()%>
      

  13.   

    首先谢谢兄弟的好意,过滤器 url改成*.action,也加了绝对路径,但是提示
    HTTP Status 404 - /SystemBBS/login.action,可是我的action在rootbbs的web-inf下面的classess里面呀。
      

  14.   

    那位有详细的struts的配置实例!最好是myEclipe + tomcat
      

  15.   

    还是一个路径问题,你可以在/login.action前面加.,如./login.jsp,加一到两个试一试。实在不行,如不建议可以把工程发给我帮你看看。邮箱:[email protected]
      

  16.   

    谢谢jian432,邮件已经发给你了,你帮忙看看,曾经是一位老师的实例,按理不会有错误呀,怎么就不行呢!
      

  17.   

    我看了你的代码,就是在连接login.jsp的时候连接写错哦,把<a href="WebRoot/login.jsp">登录</a>里面的WebRoot/去掉,去掉以后,其他代码我看了,没有问题,而且我运行了,正确的。我把代码发回给你哦,而且我看哦你好像用的是struts1.2的吧。
      

  18.   

    谢谢你得帮助,可是你把<a href="WebRoot/login.jsp"> 这里WebRoot/去掉,,index.jsp就不能访问login.jsp,如果直接访问
    http://localhost:8080/struts_login/WebRoot/login.jsp,点击提交,还是同样的错误呀!HTTP Status 404 - /struts_login/WebRoot/login.do
      

  19.   

    会不会是tomcat配置问题呢?我专门看了专门的配置视频,没有问题呀,人家都直接在tomcat5.0上成功了,我不过是tomcat6.0而已。难道需要设置一下?
      

  20.   

    谢谢你得帮助,可是你把 <a href="WebRoot/login.jsp"> 这里WebRoot/去掉,,index.jsp就不能访问login.jsp,如果直接访问 
    http://localhost:8080/struts_login/WebRoot/login.jsp,点击提交,还是同样的错误呀! HTTP Status 404 - /struts_login/WebRoot/login.do
    楼上正解
      

  21.   

    怎么 你的web.xml配置文件里没有 servlet-mapping 这个属性啊? 
      

  22.   

    对噢, 你用的是struts2,不用配置servlet-mapping, 但是前面那大哥不是说你用的是struts1.2吗?
    迷糊。。@@    嘿嘿, 学习ing..
      

  23.   


    你给我的工程里面,你的index.jsp和login.jsp是在同一个目录下面的,所以不需要在前面加WebRoot/,还有就是你报的这个错误,很明显的说明找不到你的login.do,因为你的login.do应该在struts_login目录下而不是WebRoot目录,你可以在提交的是侯在login.do前面加个/
        还有就是你给我的工程我也是用的Tomcat6.0我运行哦没有问题。
      

  24.   

    首先谢谢jian432,麻烦你在讲测试成功后的源码在发给我,同时最好能给一个具体的你得配置,还有项目存放的路径。
      

  25.   

    谢谢jian432!给我很大的支持,非常感谢!终于搞明白是什么问题了,老火了很久了!◎
    好好向你学习!