一、问题描述
请求jsp页面失败,报出异常javax.servlet.ServletException: weblogic.servlet.jsp.CompilationException: Failed to compile JSP /path/test.jsp test.jsp:6:27: Type mismatch: cannot convert from Object to String String aaList =request.getAttribute("aaList");
javax.servlet.ServletException: weblogic.servlet.jsp.CompilationException: Failed to compile JSP /path/test.jsp@b@test.jsp:6:27: Type mismatch: cannot convert from Object to String@b@ String aaList =request.getAttribute("aaList");@b@ ^-------------------------------------^@b@ at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:260)@b@ at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)@b@ at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) @b@ at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) @b@ at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)@b@ at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)@b@ at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)@b@ at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)@b@ at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:381)@b@ at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)@b@ at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:524)@b@ at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:253) @b@ at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)@b@ at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)@b@ at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)@b@ at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)@b@ at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)@b@ at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)@b@ at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) @b@ at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) @b@ at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)@b@ at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)@b@ at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)@b@ at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)@b@ at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:381)@b@ at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)@b@ at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:524)@b@ at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:253) @b@ at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)@b@ at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)@b@ at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)@b@ at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)@b@ at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)@b@ at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:183)@b@ at weblogic.servlet.ServletServlet.service(ServletServlet.java:47)@b@ at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)@b@ at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)@b@ at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)@b@ at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)@b@ at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)@b@ at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) @b@ at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) @b@ at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) @b@ at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)@b@ at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)@b@ at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)@b@ at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)@b@ at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:381)@b@ at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) @b@ at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)@b@ at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)@b@ at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)@b@ at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)@b@ at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)@b@ at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)@b@ at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)@b@ at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)@b@ at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)@b@ at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
二、解决步骤
打开对于jsp页面如/path/test.jsp中,通过String类自带方法转换Object对象,如下所示
...@b@String aaList =request.getAttribute("aaList");@b@...
修改为
...@b@String aaList =String.valueOf(request.getAttribute("aaList "));@b@...