SSM报错:No mapping found for HTTP request with URI [/smbms/js/echarts.js] in DispatcherServlet with na

在jsp引用ECharts的js包:

SSM报错:No mapping found for HTTP request with URI [/smbms/js/echarts.js] in DispatcherServlet with na_第1张图片

启动Tomcat,在地址栏输入URL:http://localhost:8080/smbms/user/linechart.html

结果页面空白,报错日志部分信息:

[DEBUG] 2017-11-11 09:32:33,160 org.springframework.web.servlet.DispatcherServlet - DispatcherServlet with name 'springmvc' processing GET request for [/smbms/js/echarts.js]
[DEBUG] 2017-11-11 09:32:33,160 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Looking up handler method for path /js/echarts.js
[DEBUG] 2017-11-11 09:32:33,161 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Did not find handler method for [/js/echarts.js]
[WARN] 2017-11-11 09:32:33,162 org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/smbms/js/echarts.js] in DispatcherServlet with name 'springmvc'
[DEBUG] 2017-11-11 09:32:33,162 org.springframework.web.servlet.DispatcherServlet - Successfully completed request


首先看一下我的web.xml配置:

SSM报错:No mapping found for HTTP request with URI [/smbms/js/echarts.js] in DispatcherServlet with na_第2张图片

可以看到,报错信息“No mapping found for HTTP request with URI [/smbms/js/echarts.js] in DispatcherServlet with name 'springmvc'”提示了说,springmvc找不到匹配HTTP请求的URI,即[/smbms/js/echarts.js进入了mvc,但是springmvc没有找到与之匹配的处理方法,因此出错。

解决办法1:

在web.xml配置文件:


    springmvc
    /
 

后面加上如下代码:

  
      default  
     *.css  
  
   
  
    default  
    *.gif   
 
  
      
    
      default  
      *.jpg  
 
  
      
    
      default  
      *.js  
 
 

重新启动tomcat服务器,运行输入

报错日志信息如下:

[DEBUG] 2017-11-11 10:21:00,640 org.springframework.web.servlet.DispatcherServlet - DispatcherServlet with name 'springmvc' processing GET request for [/smbms/user/linechart.html]
[DEBUG] 2017-11-11 10:21:00,640 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Looking up handler method for path /user/linechart.html
[DEBUG] 2017-11-11 10:21:00,640 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Returning handler method [public java.lang.String cn.smbms.controller.UserController.linechart()]
[DEBUG] 2017-11-11 10:21:00,640 org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'userController'
[DEBUG] 2017-11-11 10:21:00,640 org.springframework.web.servlet.DispatcherServlet - Last-Modified value for [/smbms/user/linechart.html] is: -1
[DEBUG] 2017-11-11 10:21:00,641 cn.smbms.controller.UserController - UserController welcome 展示折线图linechart=======================
[DEBUG] 2017-11-11 10:21:00,642 org.springframework.web.servlet.view.ContentNegotiatingViewResolver - Requested media types are [text/html;charset=UTF-8] based on Accept header types and producible media types [*/*])
[DEBUG] 2017-11-11 10:21:00,642 org.springframework.beans.factory.support.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'echarts/linechart'
[DEBUG] 2017-11-11 10:21:00,642 org.springframework.beans.factory.support.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'echarts/linechart.html'
[DEBUG] 2017-11-11 10:21:00,642 org.springframework.web.servlet.view.ContentNegotiatingViewResolver - Returning [org.springframework.web.servlet.view.JstlView: name 'echarts/linechart'; URL [/WEB-INF/jsp/echarts/linechart.jsp]] based on requested media type 'text/html;charset=UTF-8'
[DEBUG] 2017-11-11 10:21:00,642 org.springframework.web.servlet.DispatcherServlet - Rendering view [org.springframework.web.servlet.view.JstlView: name 'echarts/linechart'; URL [/WEB-INF/jsp/echarts/linechart.jsp]] in DispatcherServlet with name 'springmvc'
[DEBUG] 2017-11-11 10:21:00,642 org.springframework.web.servlet.view.JstlView - Forwarding to resource [/WEB-INF/jsp/echarts/linechart.jsp] in InternalResourceView 'echarts/linechart'
[DEBUG] 2017-11-11 10:21:00,647 org.springframework.web.servlet.DispatcherServlet - Successfully completed request

这说明js文件正常引用了。

你可能感兴趣的:(SSM)