Struts中的一个问题
12: <%
13: String name = (String) request.getAttribute( "keyname ");
14: out.println(name);
15: String keyid = (String) request.getAttribute( "id ");
16: out.println(keyid);
17: int id = Integer.parseInt(keyid);
18: out.println(keyid);
java.lang.ClassCastException: java.lang.Integer
org.apache.jsp.admin.SystemSetting.AddKeyWord_jsp._jspService(AddKeyWord_jsp.java:110)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:388)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
请问如何解决??
------解决方案--------------------看样子.LZ错的应该是这一句:
String keyid = (String) request.getAttribute( "id ");
你在看看 request.setAttribute()时是存的String型的还是Integer.