我试图让Freemarker的意见和春天开机显示首次,目前在浏览器中出现以下错误:春天开机无法解决的Freemarker视图
白色标签错误页面
这应用程序没有明确映射/错误,因此您将此视为 作为后备。
Sun Feb 19 17:59:07 GMT 2017有一个意外的错误(type = Not Found,status = 404)。没有留言可用
我正在使用Spring Boot 1.5。
我的文件结构:
的LoginController
package com.crm.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.crm.service.LoginService;
@Controller
public class LoginController {
@Autowired
private LoginService loginService;
@RequestMapping("/login")
public String authenticate() {
return "loginPage";
}
}
application.properties
spring.freemarker.template-loader-path:/
spring.freemarker.suffix: .ftl
服务器
package com.crm;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Server{
public static void main(String[] args) {
SpringApplication.run(Server.class, args);
}
}
为什么Spring无法解析loginPage.ftl视图?为什么我无法在网络浏览器中看到它?
如果您使用spring-security像我用来处理登录页面和Thymeleaf/FreeMarker一样,请确保将@EnableWebSecurity添加到您的配置中,以便正确解析资源 – rdlopes
正如上面的链接所述。模板引擎不在'src/main/java/resources/templates'中查找'src/main/resources/templates'。 – crm