springboot配置文件如下
spring.freeer.template-loader-path=classpath:/user/
spring.freeer.cache=false
spring.freeer.charset=UTF-8
spring.freeer.check-template-location=true
spring.freeer.content-type=text/html
spring.freeer.expose-request-attributes=true
spring.freeer.expose-session-attributes=true
spring.freeer.request-context-attribute=request
spring.freeer.suffix=.ftlspring.datasource.driverClassName=oracle.jdbc.OracleDriver
spring.datasource.url=jdbc:oracle:thin:@localhost:1521:orcl
spring.datasource.username=apple
spring.datasource.password=1234server.port=8080
server.session.timeout=60
server.tomcat.uri-charset=UTF-8 
    
mybatis.typeAliasesPackage=com.wr.entity
mybatis.mapperLocations=classpath:com/wr/mapper/*.xmlController类如下
@Controller
@RequestMapping("/user")
public class UserController {
       @Resource
private UserService userService;

@RequestMapping(value="/toLogin.do", method = RequestMethod.GET)
public String toLogin(){
System.out.println("----1---------2---");
User user = userService.findByUsername("apple3");
String viewName = "login";
System.out.println(user.getRealname()+","+user.getPassword());
return viewName;
// return "login";
}
}两句打印语句访问时都能正常打印,
login.ftl文件放在main/resources/user/下
然后访问就是404

解决方案 »

  1.   

    我的配置
    #ftl path
    spring.freeer.template-loader-path=classpath:/templates你的返回值是不是得加.ftl或者配置中配置
    spring.freeer.suffix=.ftl
      

  2.   

    spring.freeer.suffix=.ftl
    一直都有的
      

  3.   

    目录结构:controller:freeer:application.properties:浏览器结果:
    你的是不是其他配置冲突了
      

  4.   

    你新建项目时用sts建的吗?
      

  5.   


    你的templates文件夹是建项目时自动生成的吗?
      

  6.   


    你的templates文件夹是建项目时自动生成的吗?手动建的
      

  7.   

    没有@ResponseBody    而你是@Controller 不是@RestController
      

  8.   

    login.ftl 一定要放在main/resources/templates/ ......下
      

  9.   

    spring.freeer.template-loader-path=classpath:/user/ 改成spring.freeer.prefix=classpath:/templates/