关于与OA做单点CAS认证的时候乱码问题

解决与OA做单点CAS认证的时候乱码问题的心得

一般情况下,我们在做BS系统的时候,都有自己的一套过滤器,来处理所有访问的连接,例如

public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2)
throws IOException, ServletException
{
HttpServletRequest httpreq = (HttpServletRequest) arg0;
String forwardURL = httpreq.getRequestURI().substring(httpreq.getContextPath().length()) ;

//System.out.println("url: "+forwardURL) ;

HttpSession session = httpreq.getSession(false);
if (IsAccess(forwardURL))
{

if (session == null || session.getAttribute("AMSSession") == null)
{
HttpServletResponse httprep = (HttpServletResponse) arg1;
System.out.println("没有登陆: "+forwardURL) ;
System.out.println("没有: "+httpreq.getContextPath()) ;

String Host = httpreq.getServerName();
int port = httpreq.getServerPort();
String App = httpreq.getContextPath();
if (App==null||App.trim().equals("")||App.trim().length()==1){
App = "/";
}else{
String strlast = new String(App.substring(App.length()-1));
if (!strlast.equals("/")) App = App + "/";
}
String loginUrl = "http://"+ Host + ":" + port + App + "login.jsp";

// String loginUrl = AmsGlobals.getAmsProperty("loginURL") ;
PrintWriter out = httprep.getWriter();
out.println("<html>");
out.println("<script>");
out.println("window.top.location = '"+loginUrl+"';");
out.println("</script>");
out.println("</html>");
return ;
}
else
{
arg0.setCharacterEncoding("GBK");
arg2.doFilter(arg0, arg1);
}
}
else
{
arg0.setCharacterEncoding("GBK");
arg2.doFilter(arg0, arg1);
}
}

在这里会将所有连接通过 setCharacterEncoding 处理成GBK,不过当我们做单点的时候,可能会用到OA的一套标准,会将

OA的过滤信息添加到我们系统的WEB.XML里,如果这样,处理不好可能会导致乱码,需要在添加的时候,将不需要的过滤条件删除掉。

本文地址:http://www.xszlo.com/article/2012-11-06/7494.html,转发请保留这个地址,谢谢

你可能感兴趣的:(OA)