if ((a.indexOf(path_1) != -1)==true) {
System.out.println("trtruetruetruetruetruetruetruetruetruetrueue");
chain.doFilter(request, response);
}else{
System.out.println("falsefalsefalsefalsefalsefalsefalsefalse");
httpResponse.sendRedirect(location);
}为什么我的重定向不跳转,如果我放到true就可以跳,怎么办啊?解决全给分吧
System.out.println("trtruetruetruetruetruetruetruetruetruetrueue");
chain.doFilter(request, response);
}else{
System.out.println("falsefalsefalsefalsefalsefalsefalsefalse");
httpResponse.sendRedirect(location);
}为什么我的重定向不跳转,如果我放到true就可以跳,怎么办啊?解决全给分吧
解决方案 »
- 不知道为什么我的js报错说语法不对。。
- 问一下自动化测试的概念是最近新兴起来的吗?
- 关于附件的存放问题
- jsp 与 java script 是一个概念么??
- 登陆处理 菜鸟求助 ssh
- 文件下载问题
- 在线等大吓。。。。。。。解决!!
- Tomcat1.4.24配mysql连接池出现“ Cannot load JDBC driver class 'null'”的问题
- Java程序如何利用SOAP与VB、VC开发的软件通讯?
- 又是简单问题
- 请问怎么样能够做到wsdd文件或者是wsdl文件的拆分
- 小白求教关于<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld" %>的错误问题
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// TODO Auto-generated method stub
response.setContentType("text/html;charset=utf-8");
System.out.println("userService=" + userService);
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse =(HttpServletResponse) response;
HttpSession session = httpRequest.getSession();
String name = session.getAttribute("auser").toString();
List list = userService.QueryRole(name);
path=ServletActionContext.getRequest().getHeader("referer");
path_1 =path.substring(path.lastIndexOf("ttms/"),path.lastIndexOf(""));
System.out.println("path==="+path_1);
String NoFilter="";
String a = null;
for (int i = 0; i < list.size(); i++) {
a = list.get(0).toString();
System.out.println("aaaa==="+a);
}
boolean c=(a.indexOf(path_1) != -1);
System.out.println("cccccc====" + c);
if ((a.indexOf(path_1) != -1)==true) {
System.out.println("trtruetruetruetruetruetruetruetruetruetrueue");
chain.doFilter(request, response);
}else{
System.out.println("falsefalsefalsefalsefalsefalsefalsefalse");
httpResponse.sendRedirect(location);
}
}
localhost里面写了我的路径,没报错,也没提示哦。、在true里面就可以。。
百度也不可以跳转,他根本就没运行到那个重定义httpResponse.sendRedirect,,为什么,为什么。
但是我跳转路径是Struts2的.action路径<result></result>
System.out.println("trtruetruetruetruetruetruetruetruetruetrueue");
chain.doFilter(request, response);
}else{
System.out.println("falsefalsefalsefalsefalsefalsefalsefalse");
httpResponse.sendRedirect(location);
}
你的意思是页面上打印出来的是trtruetruetruetruetruetruetruetruetruetrueue么?
那就是执行了第一个方法呗。
如果打印falsefalsefalsefalsefalsefalsefalsefalse还没有跳转,那就是你的xml没有配置上相应的路径。
java.lang.IllegalStateException
at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:407)
另外告诉我,你页面上显示的是falsefalsefalse还是truetruetruetruetrue
不是的,我重定义的是jsp的页面,因为我要做页面权限 ,在我点击<a herf=".action">点击</a>的时候,过滤器过滤一遍。另外我页面打印的是falsefalsefalse
jsp和html一样,不用xml设定。
我想你的思路是跳转某个页面的之前,先确定下session中是否存在用户,如果不存在就重定向到登陆页面是么?
不是哦,,页面与我数据库存的权限对应,如果不存在,则重定义到我的localhost(权限不足)提示页面。
但是我这个为什么不会跳转,是不是Struts的原因了?
你改成index.html
看跳不跳转,
即使不跳转,把浏览器上的地址发给我
是的,还是不跳转。
localhost里面我是String localhost="index.jsp",其实是一样的。 但是那个为什么不跳转。是不是和我Struts配置起冲突了。
<!--Struts配置-->
<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> <welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!--Filter配置-->
<filter>
<filter-name>testFilter</filter-name>
<filter-class>com.ttms.dao.testFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>testFilter</filter-name>
<url-pattern>/admin/*</url-pattern>
</filter-mapping>
response.sendRedirect("");这里面你填的是localhost?
system.out.println("2");
判断这句话执行了没有.
另外看你的地址,/ttms/admin/user!LimitsLogin.action?newstype=1还停留在action中未动