搭建了SSH架构后 发现网页跳转过程出现了问题 用户可以通过直接输入网址跳转到没有在struts.xml里的action配置的网页 说明整个跳转过程不是完全受struts.xml控制 向前辈请教 这个问题如何解决 应该如何配置相应的xml(不要加session验证的答案 因为还没到这部)

解决方案 »

  1.   

    你的问题有点莫名其妙。如果你没有使用拦截器的话,用户肯定可以直接输入网站进行页面的浏览的。就算你放在web-inf下面别个自己写个页面链接过来也是一样的。
      

  2.   

    代码贴上来。web.xml and struts.xml
      

  3.   

    web.xml <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list> <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>-->
    <param-value>classpath:beans.xml</param-value>
    </context-param> <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>struts.xml<constant name="struts.devMode" value="true" />
    <package name="default" namespace="/" extends="struts-default">

    <action name="user*" class="com.wds.registration.action.UserAction" method="{1}">
    <result>/index.jsp</result>
    <result name="regist"> /register.jsp </result>
    <result name="log_in"> /log_in.jsp </result>
    <result name="fail">/failRegister.jsp</result>
    </action>
      

  4.   

    加个拦截器!!!加上session判断
      

  5.   

    web.xml:<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list><listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener><context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/classes/applcationContext.xml</param-value>
    </context-param><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>
    用这个再试一下看可以否。