2017-04-09 137 views
0

我有正確的配置templateResolver問題。當我嘗試獲取默認頁面時,其工作正常。當我嘗試去到頁面/ someAddress我得到Spring templateResolver配置

template might not exist or might not be accessible by any of the configured Template Resolvers 

調度-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: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/mvc 
    http://www.springframework.org/schema/mvc/spring-mvc.xsd 
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context.xsd"> 
<mvc:annotation-driven/> 
<context:component-scan base-package="com.javapointers.controllers"/> 
<bean id="templateResolver" 
     class="org.thymeleaf.templateresolver.ServletContextTemplateResolver"> 
    <property name="prefix" value="/WEB-INF/pages/"/> 
    <property name="suffix" value=".html"/> 
    <property name="templateMode" value="HTML5"/> 
</bean> 
<bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine"> 
    <property name="templateResolver" ref="templateResolver"/> 
</bean> 
<mvc:resources mapping="/resources/**" location="/WEB-INF/resources/"/> 

的HomeController

@Controller 
public class HomeController { 

@RequestMapping(value="/", method = RequestMethod.GET) 
public String viewHome(){ 
    return "test"; 
} 

@RequestMapping(value="/login", method = RequestMethod.GET) 
public String login(){ 
    return "login"; 
} 

有誰知道正確的配置?

回答

0

我解決了這個問題。在我的應用程序中是java類中的另一個bean配置。