在一个springMVC项目中遇到如下报错:
[05/06 11:44] DispatcherServlet with name 'app-servlet' processing GET request for [/user/info.html]
[05/06 11:44] Looking up handler method for path /user/info.html
[05/06 11:44] Returning handler method [public org.springframework.web.servlet.ModelAndView com.online.college.opt.controller.UserController.info()]
[05/06 11:44] Returning cached instance of singleton bean 'userController'
[05/06 11:44] Last-Modified value for [/user/info.html] is: -1
[05/06 11:44] Creating a new SqlSession
[05/06 11:44] SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@49ff4fc9] was not registered for synchronization because synchronization is not active
[05/06 11:44] Fetching JDBC Connection from DataSource
[05/06 11:44] trace com.mchange.v2.resourcepool.BasicResourcePool@6a2b346f [managed: 10, unused: 9, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@68a1e899)
[05/06 11:44] JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@3139520c] will not be managed by Spring
[05/06 11:44] ==> Preparing: SELECT realname, username, password, gender, header, mobile, status, birthday, education, college_code, college_name, cert_no, title, sign, open_id, wechat_id, qq, login_time, ip, province, city, district, weight, create_time, create_user, update_time, update_user, del, id FROM t_auth_user WHERE id = ?
[05/06 11:44] cxnStmtMgr.statementSet( com.mysql.jdbc.JDBC4Connection@7b47f122 ).size(): 4
[05/06 11:44] checkoutStatement: com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 4; checked out: 1; num connections: 1; num keys: 4
[05/06 11:44] ==> Parameters: 36(Long)
[05/06 11:44] <== Total: 1
[05/06 11:44] checkinStatement(): com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 4; checked out: 0; num connections: 1; num keys: 4
[05/06 11:44] Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@49ff4fc9]
[05/06 11:44] Returning JDBC Connection to DataSource
[05/06 11:44] checkinAll(): com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 4; checked out: 0; num connections: 1; num keys: 4
[05/06 11:44] trace com.mchange.v2.resourcepool.BasicResourcePool@6a2b346f [managed: 10, unused: 9, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@68a1e899)
[05/06 11:44] checkinAll(): com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 4; checked out: 0; num connections: 1; num keys: 4
[05/06 11:44] Returning cached instance of singleton bean 'freemarkerConfig'
[05/06 11:44] Invoking afterPropertiesSet() on bean with name 'user/info'
[05/06 11:44] Could not find template in cache, creating new one; id=["WEB-INF/pages/user/info.html"["zh_CN",UTF-8,parsed] ]
[05/06 11:44] No FreeMarker view found for URL: /WEB-INF/pages/user/info.html
[05/06 11:44] Could not complete request
javax.servlet.ServletException: Could not resolve view with name 'user/info' in servlet with name 'app-servlet'
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1211)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
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.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
由报错可知,后台已经请求到了 user/info.html并对其数据进行了处理,在访问数据库后也已经得到了返回数据,但在后台将数据返回到前端页面时出现了问题,后台数据不能在前端进行正常展示,所以找到controller层返回数据的地方发现ModelAndView返回的url没有写对
改成如下红色标记的一样,便可以运行正常