0
我知道這個問題已經很多次了,我嘗試了很多,但它不起作用。我有一些錯誤,我不知道如何處理它們。服務器看起來像不能識別jsp文件中定義的css文件和javascript文件。Org.springframework.web.servlet.dispatcherservlet nohandler發現沒有找到映射
的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" id="WebApp_ID"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<display-name>spring-mvc-crud-demo</display-name>
<welcome-file-list>
<welcome-file>Index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-mvc-crud-demo-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
servlet.xml中
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- Add support for component scanning -->
<context:component-scan base-package="com.controller" />
<!-- Add support for conversion, formatting and validation support -->
<mvc:annotation-driven />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WebContent/" />
<property name="suffix" value=".jsp" />
</bean>
控制器
package com.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping(value= "/intent", method= RequestMethod.POST)
public class IntentController {
@RequestMapping("/notepad")
public String Notepad(){
System.out.println("Notepad is redy");
return "Index";
}
錯誤 服務器沒有看到css文件和javascript。
Sep 21, 2017 11:32:06 AM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/ApiAi/assets/css/noscript.css] in DispatcherServlet with name 'dispatcher'
Sep 21, 2017 11:32:06 AM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/ApiAi/assets/js/jquery.min.js] in DispatcherServlet with name 'dispatcher'
Sep 21, 2017 11:32:06 AM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/ApiAi/assets/css/mainCss.css] in DispatcherServlet with name 'dispatcher'
Sep 21, 2017 11:32:06 AM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/ApiAi/assets/js/skel.min.js] in DispatcherServlet with name 'dispatcher'
Sep 21, 2017 11:32:06 AM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/ApiAi/assets/js/util.js] in DispatcherServlet with name 'dispatcher'
Sep 21, 2017 11:32:06 AM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/ApiAi/assets/js/main.js] in DispatcherServlet with name 'dispatcher'
Sep 21, 2017 11:32:06 AM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/ApiAi/images/pic03.jpg] in DispatcherServlet with name 'dispatcher'
是的,這是問題,並且我沒有資源文件夾中的css文件 –