package fiters;
import javax.servlet.filter;
import javax.servlet.*;
import java.io.ioexception;
import javax.servlet.http.*;

public class ogfiters implements filter{

 public void init(filterconfig parm1) throws servletexception {
  // todo: add your code here
 }


 public void dofilter(servletrequest request, servletresponse response,
    filterchain chain) throws ioexception, servletexception
 {
  httpservletrequest hsrequest = (httpservletrequest)request;
  httpservletresponse hsresponse = (httpservletresponse)response;
  request.setcharacterencoding("gb2312");
  response.setcharacterencoding("gb2312");
 
  /*httpsession session = hsrequest.getsession();
 
  //没登录
  if(session.getattribute("username")==null)
  {
  
   string uri = hsrequest.getrequesturi();
   //请求登录页面
   if(uri.endswith("login.html")|| uri.endswith("login"))
   {
    chain.dofilter(request,response);
   }
   //请求其它页面
   else
   {
    hsresponse.sendredirect("login.html");
   }
  
  }
  //登录成功
  else
  {
   chain.dofilter(request,response);
  }*/
  chain.dofilter(request,response);
 
 
 
 }

 
 public void destroy() {
  // todo: add your code here
 }

}
web.xml配置
http://java.sun.com/xml/ns/j2ee" xmlns:xsi="" version="2.4" xsi:schemalocation="   ">
    
  loginfilter
  fiters.ogfiters
 

 
  loginfilter
  *.do
 

 

posted on 2011-06-29 15:46 sanmao 阅读(2933) 评论(0)    

只有注册用户后才能发表评论。


网站导航:
              
 

常用链接

留言簿(5)

java 过滤器配置 -凯发k8网页登录

搜索

  •  

最新评论

阅读排行榜

评论排行榜

网站地图