我的项目是用struts1.2 做的,我的jsp页面跳转都是通过配制文件进行跳转的, <!--菜单出勤天数统计跳转 -->
<action path="/T_attendancedate"
type="org.apache.struts.actions.ForwardAction"
parameter="/principalconsulting/attendancedate.jsp?key=1" />
这个是我的过滤器,public class LoginFilter extends HttpServlet implements Filter { @Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain china) throws IOException, ServletException {
HttpServletRequest res = (HttpServletRequest) request;
HttpServletResponse respon = (HttpServletResponse) response;
HttpSession session = res.getSession();
if (session.getAttribute("name") == null) {
respon.sendRedirect(res.getContextPath() + "/loginno.do");
System.out.println("非法登陆");
} else {
china.doFilter(request, response);
}
} @Override
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
// System.out.println("****");
}}//这个是我的web.xml  <filter>
  <filter-name>login</filter-name>
  <filter-class>loginfilter.LoginFilter</filter-class>
  </filter>
  <filter-mapping>
  <filter-name>login</filter-name>
  <url-pattern>/rxdj/*</url-pattern>
  </filter-mapping>现在的问题是这样的,我用http://localhost:8080/NMSoftware/principalconsulting/attendancedate.jsp?key=1这个地址直接访问jsp页面,是可以过滤的,但是我用,http://localhost:8080/NMSoftware/T_attendancedate.do 通过配制文件在访问就过滤不到了,,,,,,,,,,,大家帮帮忙看下啊。

解决方案 »

  1.   

    loginfilter.LoginFilter
    有这个过滤器吗,你第一种写法是直接请求action了,当然给你响应了!
      

  2.   

    还有就是 ,必须要用post提交
      

  3.   

    本帖最后由 kokobox 于 2010-12-30 11:41:53 编辑
      

  4.   

    <url-pattern>/rxdj/*</url-pattern>
    你的拦截有问题。改成拦截所有 去掉rxdj
      

  5.   


    如果改成这样,<url-pattern>/rxdj/*</url-pattern>
    那么登陆login.jsp页面也过滤了,这样就会一直在login.jsp,不断刷新,,登陆不进去啊。
      

  6.   


    <url-pattern>/*</url-pattern>//改成这样,就进不去登陆页面啦。是不行的。
      

  7.   

    你把登陆界login.jsp 页面单独放,然后其他的都放在一个文件下面,然后过滤哪个文件下面的所有
      

  8.   

      <action path="/T_attendancedate"
                type="org.apache.struts.actions.ForwardAction"
                parameter="/principalconsulting/attendancedate.jsp?key=1" />
    parameter 是决定你调用方法的参数属性
    跳转页面时用<forward >节点

      <action path="/news" type="com.ambow.struts.action.NewsAction" parameter="method">
         <forward name="query" path="/news.jsp"/>
         <forward name="list" path="/news.do?method=query"/>
       </action>
      

  9.   


    我也不能把所有的jsp页面都放在一个夹下啊,这样管理起来太麻烦啦。
      

  10.   


    我说老大~您不会在过滤器里面把login .jsp和它相关的样式表和图片放开让他通过啊~
    在filter里面判断一下啊~
    if(request.getServletPath().equalsIgnoreCase("/admins/login.jsp")){
    chain.doFilter(arg0, arg1);
    }
      

  11.   

    晕 老大,其他的文件夹也不一定要放在同一个文件夹下哇 你配置文件里过滤除了login所在的各个文件夹不就好了吗?
      

  12.   

    做过个类似的过滤器,简单说一下思路if(判断用户信息是否为空){
        if(判断请求路径是否是jsp或者.do){
            if(判断请求路径是否是/login.jsp)){
        //放过
    }else{
        //跳转到错误页或者登录页
    }
        }else{
    //不是jsp或者.do的其它请求放过
        }
    }else{
        //有登录信息的所有放过~
    }
      

  13.   

    现在的问题以经解决了,我现在访问
    http://localhost:8080/NMSoftware/Alclo.do,http://localhost:8080/NMSoftware/rxde/student.jsp 这两个地址是可以拦截了,但是我现在访问这个地址http://localhost:8080/NMSoftware/Alclo.do?method=adString  就是后带了人方法,就报错了。。这样过滤器就不拦截了,,,,。
      

  14.   

    LZ你是不是还是拦截的/rxdj/*
    那样他只会拦截/rxdj下面的东西~其它的不会拦截~
      

  15.   

    不行你就把配置文件里面的/Alclo
    映射成/rxdj/Alclo
      

  16.   

    现在都可以了,现在是这样的,如果没有登陆 http://localhost:8080/NMSoftware/Alclo.do和http://localhost:8080/NMSoftware/Alclo.do?method=adString  这两个地址都是可以拦载的,
    如果我登陆成功,我在直接访问http://localhost:8080/NMSoftware/Alclo.do?method=adString这个带参数的地址就会出错,。