springboot-使用jfinal-enjoy模板
作者:互联网
最近在看jfinal框架,然后记录下自己上手的知识。
有点像天下武功,唯快不破,来试下enjoy模板引擎
文章目录
简单高效
为什么使用Jfinal Enjoy作为前端页面渲染?简单高效
1.引入Enjoy
<dependency>
<groupId>com.jfinal</groupId>
<artifactId>enjoy</artifactId>
<version>4.5</version>
</dependency>
2.EnjoyConfig
代码如下:
package com.example.demo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.jfinal.template.ext.spring.JFinalViewResolver;
import com.jfinal.template.source.ClassPathSourceFactory;
@Configuration
public class EnjoyConfig {
@Bean
public JFinalViewResolver jFinalViewResolver() {
JFinalViewResolver jfr = new JFinalViewResolver();
jfr.setDevMode(false);
jfr.setSourceFactory(new ClassPathSourceFactory());
//设置模板根路径
jfr.setPrefix("/templates/");
//设置模板后缀
jfr.setSuffix(".html");
jfr.setContentType("text/html;charset=UTF-8");
jfr.setOrder(0);
return jfr;
}
}
现在还有点小问题,前端代码修改后,刷新不能及时同步
前端代码
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<a href="index_3.html">首页</a>
#(name)
</body>
</html>
Controller
@Controller
public class indexController {
@GetMapping("/login")
public String getzxx(Model model){
model.addAttribute("name", "张三");
return "/login/login";
}
}
标签:enjoy,springboot,JFinalViewResolver,jfr,jfinal,import,com,public 来源: https://blog.csdn.net/Wyangcsdb/article/details/113917452