刚开始学的struts2 看的马士兵的视频。
按着视频里的敲的 可是第一个程序就报了 404 错误

解决方案 »

  1.   

    <?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">
      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
      
      <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>
    </web-app>这是web.xml
      

  2.   

    <struts>

        <!-- Add packages here -->
     
         <constant name="struts.devMode" value="true" />
     <package name="default" namespace="/" extends="struts-default">
            
            <action name="hello">
                <result>
                    /index.jsp
                </result>
            </action>
        </package></struts>
    这是 struts.xml
      

  3.   

    HTTP Status 404 -type Status reportmessagedescription The requested resource () is not available.
    Apache Tomcat/6.0.26这是错误页
      

  4.   

            <action name="hello">  //这里没有指定method ,,看你对应action类是否是execute()
                <result>   //这里没有指定 name ,,
                    /index.jsp
                </result>
            </action>
      

  5.   

    <action name="hello">要指定是哪个类的execute方法
      

  6.   

    看看tomcat是否有错误报出,另外,你的url会不会有问题呢,那几个步骤是一个都不能少的
      

  7.   


    在xml的action中少了class属性,如class="package_name.action_name"
      

  8.   

    <action name="hello">要指定是哪个类的哪个方法,你类以及方法都没指定,怎么能从访问到相应的Action呢?
      

  9.   

        <filter>
            <filter-name>struts2</filter-name>
            <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
        </filter>
    试试着个过滤的写法
      

  10.   

    我昨天也遇到了这个问题。是因为 服务器指向的问题。
    马士兵的是已经配好的TOMCAT.
    参照这个方法:
    http://blog.csdn.net/wqjsir/article/details/7169838
      

  11.   

    链接是eclipse的 我用的是Myeclipse呀
      

  12.   

      指定到那个CLASS 
      

  13.   


    要怎么写?
    现在问题确定了。
    tomcat启动就出问题了
    严重: Error filterStart
    2013-3-17 14:38:23 org.apache.catalina.core.StandardContext start
    严重: Context [/lllll] startup failed due to previous errors
    2013-3-17 14:38:24 org.apache.catalina.core.StandardContext start
      

  14.   

    严重: Error filterStart
    2013-3-17 19:53:58 org.apache.catalina.core.StandardContext startInternal
    严重: Context [/Struts2_0100_Introduction] startup failed due to previous errors2013-3-17 19:53:58 org.apache.catalina.loader.WebappClassLoader checkThreadLocal
    MapForLeaks
    严重: The web application [/Struts2_0100_Introduction] created a ThreadLocal wit
    h key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.open
    symphony.xwork2.inject.ContainerImpl$10@1fb3211]) and a value of type [java.lang
    .Object[]] (value [[Ljava.lang.Object;@940b84]) but failed to remove it when the
     web application was stopped. Threads are going to be renewed over time to try a
    nd avoid a probable memory leak.
    2013-3-17 19:53:58 org.apache.catalina.loader.WebappClassLoader checkThreadLocal
    MapForLeaks
    严重: The web application [/Struts2_0100_Introduction] created a ThreadLocal wit
    h key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.open
    symphony.xwork2.inject.ContainerImpl$10@18041e0]) and a value of type [java.lang
    .Object[]] (value [[Ljava.lang.Object;@16504fa]) but failed to remove it when th
    e web application was stopped. Threads are going to be renewed over time to try
    and avoid a probable memory leak.
       现在大概总结到这个问题 
    求大神啊!!!!
      

  15.   

    404报错多了感觉很正常。我当初学servlet的时候也报错404
    最头痛的时还找不到错。
      

  16.   

    能写一个简单的struts的项目让我看一下嘛 。
    我是按着视频敲的  结果还不对。把我弄的无从下手了。 网上找解决方法。都试过了 也不行啊
    [email protected]
      

  17.   

    环境不一定一样。
    另外struts2我记得有一点很怪异的就是明明配置好了。但是有时候就是提示找不到对应的返回值,但是struts.xml文件是没有问题的。。clean工程,清空缓存都没有,重启下电脑之后竟然就好了。。
      

  18.   

    我不明白为什么一个简单的404给涉及到了过滤器。。
    简单的话你发一下web.xml和struts.xml就可以了
      

  19.   

    404错误就是没找着。我刚学习的时候也和你一样,各种404错误
    我猜你是图方便不想重复配置struts,就直接copy人家的或以前的项目到自己的机子上就直接运行了,其实这时运行的还是之前的那个项目名,这样当然找不到。初学者必犯错误
    右击项目名--->properties----->myEclipse----->找到web contextroot,改成你要运行的项目名,就是你当前的项目名。
    如果不是,那就是struts配置错了
      

  20.   

    action没配置类名,配置好了。注意核对访问的URL,项目名、namespace、action路径、action后缀都别写错了。
      

  21.   


    我用别的方式  倒是成功了  不知道为什么这个按视频敲的就是不行。  项目名也没问题。
     不过我把那个项目的web.xml 改回没写之前的就不报404错误了 
      

  22.   

    如果只是实现转发到某个JSP页面,是不用写Action类的,只是在struts.xml中配置action就行,配置时就不用指定class了。差不多就是你2楼的配置那样。你在看下你的访问路径有没问题吧。
    访问路径中的项目路径、action后缀,.do.action试下就好了。
    还是不行,就按标准配置写个action 吧。
      

  23.   

    beijing20110905 正解。的确是这样的,如果只是实现转到某个JSP页面,是不用指定Action类的,action的标签内不需要指定class也不需要指定method。默认的是class是ActionSupport这个类,默认的方法是ActionSupport中的execute方法。
      

  24.   

    <action name="hello" class="项目下HelloAction的路径">
      

  25.   

      <action name="hello">
                <result>
                    /index.jsp
                </result>
       </action>
    class属性都没写,不报错就不正常了,找到你action类的路径:报名.类名
    如: <action name="hello" class="com.ssh.XXXXAction">
                <result>
                    /index.jsp
                </result>
       </action>
      

  26.   

    我认为是你的路径写错了 ,你要带上/hello估计可以 试试 肯定是路径的问题
      

  27.   


    正解!这里指定name="success"或其它…………
      

  28.   

    我也在看马士兵的stutrs2的视频,有点晕