Spring mvc 当我添加MVC:resources映射时,JavaSpringMVC不起作用
我是Spring和JavaEE的新手。下面是我的一个非常简单的应用程序: web.xmlSpring mvc 当我添加MVC:resources映射时,JavaSpringMVC不起作用,spring-mvc,jakarta-ee,glassfish-4.1,Spring Mvc,Jakarta Ee,Glassfish 4.1,我是Spring和JavaEE的新手。下面是我的一个非常简单的应用程序: web.xml mvc调度器 org.springframework.web.servlet.DispatcherServlet 1. mvc调度器 / mvc-dispatcher-servlet.xml: 控制器: @控制器 @请求映射(“/”) 公共类Hello控制器{ @RequestMapping(method=RequestMethod.GET) 公共字符串printWelcome(ModelMap模型
mvc调度器
org.springframework.web.servlet.DispatcherServlet
1.
mvc调度器
/
mvc-dispatcher-servlet.xml:
控制器:
@控制器
@请求映射(“/”)
公共类Hello控制器{
@RequestMapping(method=RequestMethod.GET)
公共字符串printWelcome(ModelMap模型){
列表)。玻璃鱼日志:
[2015-03-04T17:15:54.595+0400][glassfish 4.1][警告]]
[org.springframework.web.servlet.PageNotFound][tid:_ThreadID=31
_ThreadName=http-listener-1(1)][timeMillis:1425474954595][levelValue:900][[未找到具有URI的http请求的映射
[/untitled_war_explosed/]在名为
“mvc调度程序”]]
[2015-03-04T17:15:54.745+0400][glassfish 4.1][警告]]
[org.springframework.web.servlet.PageNotFound][tid:_ThreadID=34
_ThreadName=http-listener-1(4)][timeMillis:1425474954745][levelValue:900][[未找到具有URI的http请求的映射
[/untitled_war_explosed/]在名为
“mvc调度程序”]]
[2015-03-04T17:16:02.191+0400][glassfish 4.1][警告]]
[org.springframework.web.servlet.PageNotFound][tid:_ThreadID=33
_ThreadName=http-listener-1(3)][timeMillis:1425474962191][levelValue:900][[未找到具有URI的http请求的映射
[/untitled_war_explosed/]在名为
“mvc调度程序”]]
文件树:
├───.idea
│ ├───artifacts
│ ├───copyright
│ ├───libraries
│ └───scopes
├───lib
├───out
│ └───artifacts
│ └───untitled_war_exploded
│ ├───resources
│ │ └───bootstrap
│ │ ├───css
│ │ ├───fonts
│ │ └───js
│ └───WEB-INF
│ ├───classes
│ │ └───ru
│ │ └───javaheap
│ │ └───entity
│ ├───lib
│ ├───pages
│ └───resources
│ └───bootstrap
│ ├───css
│ ├───fonts
│ └───js
├───src
│ ├───main
│ │ ├───java
│ │ │ └───ru
│ │ │ └───javaheap
│ │ │ └───entity
│ │ └───resources
│ └───test
│ └───java
├───target
│ ├───classes
│ │ └───ru
│ │ └───javaheap
│ │ └───entity
│ └───generated-sources
│ └───annotations
└───web
├───resources
│ └───bootstrap
│ ├───css
│ ├───fonts
│ └───js
└───WEB-INF
└───pages
下面的配置应该适合您,您基本上缺少元素
<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: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">
<context:component-scan base-package="ru.javaheap"/>
<mvc:annotation-driven/>
<mvc:resources mapping="/resources/**" location="/resources/"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>