description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.ClassCastException: com.sany.web.session.WebSession cannot be cast to java.lang.String
com.sany.web.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:34)》<!--->
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.35 logs.
/**
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import com.sany.util.log.ILogger;
public class SetCharacterEncodingFilter implements Filter {
private static final ILogger logger = ILogger.getInstance().getILogger(SetCharacterEncodingFilter.class);
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain fileter) throws IOException, ServletException {
// TODO Auto-generated method stub
request.setCharacterEncoding("GBK");
HttpServletRequest req = (HttpServletRequest) request;
// response.setCharacterEncoding("GBK");
try{
fileter.doFilter(request, response);
}
catch(Exception e){
logger.error((String)req.getSession().getAttribute("user"),"doFilter(ServletRequest request=" + request
+ ", ServletResponse response=" + response
+ ") - [方法錯誤]", e);
e.printStackTrace();
}
}
public void destroy() {
// TODO Auto-generated method stub
}
}
com.sany.web.session.WebSession cannot be cast to java.lang.String
類型轉換錯誤 應該用WebSession接的你用的是String
錯誤在etCharacterEncodingFilter.java:34