嘿,我创建了一个简单的ServletConfig示例,其中有3个文件-- index.htm、ServletConfig.java和web.xml。但在运行该项目时,我得到了以下错误:
HTTP Status 500 - org.apache.catalina.core.StandardWrapperFacade cannot be cast to S_Config.ServletConfig
type Exception report
message org.apache.catalina.core.StandardWrapperFacade cannot be cast to S_Config.ServletConfig
description The server encountered an internal error that prevented it from fulfilling this request.
exception
java.lang.ClassCastException: org.apache.catalina.core.StandardWrapperFacade cannot be cast to S_Config.ServletConfig
S_Config.ServletConfig.doPost(ServletConfig.java:25)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.28 logs.可以帮我一个忙。我的ServletCongif.java文件就像这个
package S_Config;
import javax.servlet.http.*;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
/**
*
* @author user
*/
public class ServletConfig extends HttpServlet {
@Override
protected void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter pw = res.getWriter();
ServletConfig conf = (ServletConfig) getServletConfig();
String s1 = conf.getInitParameter("n1");
String s2= conf.getInitParameter("n2");
pw.println("The value of n1 is"+s1+" "+"The value of n2 is "+s2);
pw.close();
}
}发布于 2015-10-18 08:50:48
https://stackoverflow.com/questions/33195893
复制相似问题