请教springMvc的相关问题

jike_daredevil2 SpringMVC 快速入门 最后由 rubyzhu 于09月22日回复

  • 1 回答
  • 219 浏览

问题是这样的,我在前端有一个请求,请求的url是这样的:/bss/login/getMenuTree.do。控制层代码如下:

@RequestMapping("/bss/login/getMenuTree")public void getMenuTree(HttpServletResponse response) {    String json = "";    try {        String root_id = getRequest().getParameter("top_id");        List<Map<String, Object>> treeList = loginService.getMenuTree(root_id, getRequest());        treeList = CommUtil.listMapKeyToLower(treeList);        json = JsonStringUtils.listToJsonString(treeList);    } catch (Exception e) {        logger.error("", e);    }    CommUtil.sendMsgToFrontEnd(response, json);}

问题是这样的,如果上述代码中的response,我使用

((ServletRequestAttributes)
RequestContextHolder.getRequestAttributes()).getResponse()

来获取,那么执行完毕后,在tomcat localhost log中,就会报错,错误是这样的:

08-Sep-2017 12:19:17.135 严重 [http-nio-8080-exec-8] org.apache.catalina.core.ApplicationDispatcher.invoke Servlet.service() for servlet [jsp] threw exception

 javax.servlet.ServletException: File [/WEB-INF/page/bss/login/getMenuTree.jsp] not found

at org.apache.jasper.servlet.JspServlet.handleMissingResource(JspServlet.java:407)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:374)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728)

at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:590)

at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:524)

at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:160)

at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)

at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1244)

at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027)

at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971)

at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)

at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)

at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)

at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)

at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)

at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)

at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)

at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1457)

at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProce