对不起,标题应该是转发而不是重发。即forward

解决方案 »

  1.   

    肯定是能forward  .do的
    你这个报错应该是你的/login/loginLogin.do配置有问题
      

  2.   

    谢谢回复,可是我在地址栏里输入http://localhost/mmp/login/loginLogin.do是可以执行的。
    难道是这种loginLogin.do这种写法forward不支持?
      

  3.   

    <!DOCTYPE struts PUBLIC 
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
    <struts>
    <!-- Configuration for the member package. -->
    <package name="Login" namespace="/login" extends="struts-default">
    <action name="*Login" method="{1}" class="com.tongcard.merchant.web.actions.login.LoginAction">
    <result name="input">/login/login.jsp</result>
    <result name="success">/main.jsp</result>
    <result name="logout">/login/login.jsp</result>
    </action>
    </package>
    </struts>
      

  4.   

    哦。发上去看到,是不是package的name大写造成的,试试。:)
      

  5.   

    404错误一般是路径不正确
    建议你把这个完整的路径打出来看看。。
    、loginLogin.do这种写法forward 是支持的
    我以前经常这么写对了
    你是不是req.getRequestDispatcher( "/login/loginLogin.do ").forward(req,res); 
    do后面多了个空格啊
      

  6.   

    格式是正确的。也不是package name的问题。
      

  7.   

    LZ,把你的整个web.xml贴出来看一下,发代码用CSDN编辑器中的贴代码功能吧,这样太难看了
      

  8.   

    郁闷呀,想放弃了。这是为什么呀,这样的贴子在javaeye直接被评为入门詀。可是我的问题确实存在呀。
      

  9.   


    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="demo-website" version="2.4"
    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_4.xsd"> <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
    classpath:config/spring/spring-application.xml
    </param-value>
    </context-param> <context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>operation_portal.root</param-value>
    </context-param> <context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>classpath:config/log4j.properties</param-value>
    </context-param> <context-param>
    <param-name>log4jRefreshInterval</param-name>
    <param-value>60000</param-value>
    </context-param> <listener>
    <listener-class>
    org.springframework.web.util.Log4jConfigListener
    </listener-class>
    </listener> <listener>
    <listener-class>
    org.springframework.web.util.IntrospectorCleanupListener
    </listener-class>
    </listener> <listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListener
    </listener-class>
    </listener>    <context-param>
           <param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
           <param-value>/WEB-INF/classes/config/tiles/tiles-defs.xml,
                        /WEB-INF/classes/config/tiles/tiles-member-defs.xml,
                        /WEB-INF/classes/config/tiles/tiles-merchant-defs.xml,
                        /WEB-INF/classes/config/tiles/tiles-point-defs.xml,
                        /WEB-INF/classes/config/tiles/tiles-sales-defs.xml,
                        /WEB-INF/classes/config/tiles/tiles-trade-defs.xml
           </param-value>
        </context-param>
     
        <listener>
           <listener-class>
               org.apache.struts2.tiles.StrutsTilesListener
           </listener-class>
        </listener> <filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>
    org.springframework.web.filter.CharacterEncodingFilter
    </filter-class>
    <init-param>
    <param-name>encoding</param-name>
    <param-value>UTF-8</param-value>
    </init-param>
    </filter> <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping> <filter>
    <filter-name>CheckCookieFilter</filter-name>
    <filter-class>
    com.tongcard.merchant.web.filter.CheckCookieFilter
    </filter-class>
    </filter>
    <filter-mapping>
    <filter-name>CheckCookieFilter</filter-name>
    <url-pattern>/index.jsp</url-pattern>
    </filter-mapping>
    <filter>
    <filter-name>struts2</filter-name>
    <filter-class>
    org.apache.struts2.dispatcher.FilterDispatcher
    </filter-class>
    <init-param>
    <param-name>actionPackages</param-name>
    <param-value>com.tongcard.merchant.web.actions</param-value>
    </init-param>
    </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>index.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
    <welcome-file>default.htm</welcome-file>
    </welcome-file-list>
    </web-app>
      

  10.   

    这样做失败的原因如下:
        当你的请求进来,到CheckCodeFilter的时候,你对cookie进行的判断,如果取不到Cookie的内容,就跳转到你说的login.do,这个是不会错的。
    但在Filter中没有执行你的chain.doFilter()方法,这样的话接下来的请求将不会去走你的struts2这个Filter,那么你的Action也就映射不过去了,
    所以会报404错误。这是我的理解,如果有达人发现有问题,请帮我指出来,共同学习。建议:
        不要在Filter里面做这样的判断,在Action里面去判断,比如加个Index.do之类的,这样就不会有问题了,希望能帮到楼主
      

  11.   

    刚才想到,咱天试对于JSP是可以定位的。这可能就不是拦截器顺序的问题了。
      

  12.   

    JSP可以定位是因为你那确实有这个JSP文件
      

  13.   

    我想知道如果使用filter的话,而不使用你所说的index.do。能不能做到?
    是不是定位jsp不需要走struts2的org.apache.struts2.dispatcher.FilterDispatcher,而类似于.do什么的就需要这个类去翻译。请grubbyfan兄指教。
      

  14.   

    1. 我想了一下,如果使用filter,你判断之后必然要转发,一转发的话势必就执行不到接下来的filter了,这个我觉得是不太好解决的!
    2. 如果你用filter,那么当你进行转发的时候,Servlet容器会直接去找那个文件,比如你这里是/login/loginLogin.do,假设你的login目录下真的有
        loginLogin.do这个文件,那么它也是可以找的到的(你不信可以试一下),所以不管是定位什么文件,只要它存在,就可以找到。
    3. 建议:考虑通用性的话你可以通过自定义一个拦截器实现(Interceptor),Struts2里面自定义Interceptor很简单的,你可以参考这篇文章
        http://www.blogjava.net/max/archive/2006/12/06/85925.html