配置文件:
<?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: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-4.3.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd">
<!-- <bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/"></property>
<!– 视图名后缀 –>
<property name="suffix" value=".html" />
</bean>-->
<!-- 加载静态资源 -->
<mvc:default-servlet-handler />
<mvc:annotation-driven />
<bean id="velocityConfig"
class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="resourceLoaderPath">
<value>/WEB-INF/</value>
</property>
<property name="velocityProperties">
<props>
<prop key="input.encoding">UTF-8</prop>
<prop key="output.encoding">UTF-8</prop>
<prop key="contentType">text/html;charset=UTF-8</prop>
<prop key="file.resource.loader.cache">false</prop>
<prop key="file.resource.loader.modificationCheckInterval">1</prop>
<prop key="velocimacro.library.autoreload">true</prop>
</props>
</property>
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
<property name="suffix" value=".html" />
<!-- <!– 使用springMacro、使用servlet的对象 –>-->
<property name="exposeSpringMacroHelpers" value="true" />
<property name="exposeRequestAttributes" value="true" />
<property name="exposeSessionAttributes" value="true" />
<property name="requestContextAttribute" value="rc" />
<property name="dateToolAttribute" value="date" /><!--<!–日期函数名称–>-->
<property name="contentType" value="text/html;charset=UTF-8" />
</bean>
</beans>
java代码:
@Controller
@RequestMapping("/test")
public class TestController {
@RequestMapping(value = "/test", method = {RequestMethod.GET})
public String merchantLogin(HttpServletRequest request, ModelMap modelMap) throws Exception {
return "/html/test";
}
}
html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title11111111</title>
</head>
<body>
222222222222222222
</body>
</html>
第一张图是报错信息,下面是控制台输出信息
[ERROR] velocity: ResourceManager : unable to find resource '/html/test.html' in any resource loader.
分不多见谅,求助!!!