程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> description-關於tomcat 報錯原因

description-關於tomcat 報錯原因

編輯:編程綜合問答
關於tomcat 報錯原因

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.

/**

  • */ package com.sany.web.filter;

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

csuuniversity
u011376884
csuuniversity
u011376884
u011376884
csuuniversity
u011376884
csuuniversity
u011376884
csuuniversity
u011376884
csuuniversity
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved