当前位置: 首页 > news >正文

河北省住房城乡建设厅网站施工企业工作环境

河北省住房城乡建设厅网站,施工企业工作环境,公司logo如何设计,地产公司做网站维护写代码么6虽然目前市场上多数的开发模式采用前后端分离的技术#xff0c;视图层的技术在小一些的项目中还是非常有用的#xff0c;所以一直也占有一席之地#xff0c;如spring官方的spring.io等网站就是使用视图层技术实现的。 目前Spring Boot支持的较好的两个视图层模板引擎是Thyme… 虽然目前市场上多数的开发模式采用前后端分离的技术视图层的技术在小一些的项目中还是非常有用的所以一直也占有一席之地如spring官方的spring.io等网站就是使用视图层技术实现的。 目前Spring Boot支持的较好的两个视图层模板引擎是Thymeleaf和FreeMarker其中Thymeleaf是默认的模板引擎。 一、整合Thymeleaf Thymeleaf支持HTML原型可以直接在浏览器中查看页面样式这对于调试是非常方便的SpringBoot工程整合Thymeleaf只需要几个简单的步骤 添加依赖 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-thymeleaf/artifactId/dependency 配置Thymeleaf Springboot中Thymeleaf默认的配置类为ThymeleafAutoConfiguration默认的模板以html格式存在于classpath:/templates目录下如果要改变这些配置可以在application.properties中修改所有的配置以spring.thymeleaf为前缀 #是否启用thymeleaf默认true spring.thymeleaf.enabledtrue #是否开启缓存默认true spring.thymeleaf.cachetrue #检查模板是否存在默认为true spring.thymeleaf.check-templatetrue #检查模板位置是否存在默认为true spring.thymeleaf.check-template-locationtrue #开启EL编译器默认为true spring.thymeleaf.enable-spring-el-compilertrue #配置模版的位置 spring.thymeleaf.prefixclasspath:/templates/ #配置模板的编码 spring.thymeleaf.encodingUTF-8 #配置模版支持的类型默认为HTML spring.thymeleaf.modeHTML #配置模板文件的后缀默认为.html spring.thymeleaf.suffix.html #配置content-type spring.thymeleaf.servlet.content-typetext/html 3.配置ModelAndView 编写controller返回一个ModelAndView返回到页面上渲染的数据存储在ModelAndView中。 Controller RequestMapping(/thymeleaf) public class ThymeleafController {private class Student{private String name;private int age;public String getName() {return name;}public void setName(String name) {this.name name;}public int getAge() {return age;}public void setAge(int age) {this.age age;}}GetMapping(/students)public ModelAndView students(){ListStudent students new ArrayList();Student student1 new Student();student1.setName(Li Lei);student1.setAge(18);Student student2 new Student();student2.setName(Han Meimei);student2.setAge(17);students.add(student1);students.add(student2);ModelAndView modelAndView new ModelAndView();modelAndView.addObject(students,students);modelAndView.setViewName(test);return modelAndView;} } 4.编写template 在resources目录下创建templates文件创建test.html对应上面代码的viewName,填入以下内容 !DOCTYPE html html langen xmlns:thhttp://www.thymeleaf.org headmeta charsetUTF-8titleThymeleaf Testing/title /head styletr,td,th {border: 2px solid #ff4c6b;width: 200px;} /style body styletext-align:center; table stylemargin:200px auto;border: 2px solid #ff4c6b;trtd姓名/tdtd年龄/td/trtr th:eachstudent:${students}td th:text${student.name}/tdtd th:text${student.age}/td/tr /table /body /html 访问localhost:8080/thymeleaf/students得到以下页面 二、整合FreeMarker 整合FreeMarker于Thymeleaf非常相似springboot提供了一致的整合方案所以你只需要将以上的步骤做一下修改 1、添加依赖 将Thymeleaf依赖替换成FreeMarker依赖 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-freemarker/artifactId/dependency 2、修改模板 将原来建立的html模板改成.ftl模板其余不变。
http://www.w-s-a.com/news/184826/

相关文章:

  • 专业的手机网站建设公司哪家好同城信息网站建设
  • 参与做网站的收获国外网站服务器建设
  • 西宁网站建设报价cu君博规范网站kv如何做
  • 毕业室内设计代做网站广东建设监理协会网站个人账号
  • 百度推广点击收费标准自己如何做网站优化
  • 安徽省建设监理网站广州澄网站建设公司
  • 做简历用什么网站俄罗斯搜索引擎浏览器官网入口
  • dw里响应式网站怎么做制作网站需要多少时间
  • 网站如何做双链路示范学校建设专题网站
  • 网站开发北京影视网站seo描述
  • 高端网站定制建设公司哪家好企业网络推广技巧
  • 建设公司网站的内容建筑设计图片
  • 用ps怎么做网站的效果图互联网营销师报名入口官网
  • 网站的后端怎么开发网站 白名单
  • 济宁中小企业网站建设wordpress爆破工具
  • 零基础网站建设视频商城系统平台有哪些
  • 那个网站做百科好过wordpress删除
  • 优化网站排名怎么制作网站建设数据库模板
  • 哪个建站软件比较好带论坛都有什么公司需要网站建设
  • 同城便民网站开发自己免费怎么制作网站吗
  • 数据库网站开发教程网站内部优化是什么意思
  • 哈尔滨建站怎么做广西seo快速排名
  • 公司网站建设的不足企业文档管理wordpress
  • .net做的网站代码网站怎么加二级域名
  • 网站建设方案对比分析报告成都短视频代运营
  • 企业所得税税率知多少重庆seo什么意思
  • ftp如何修改网站备案号百度云建站
  • 免费做网站空间dede二手车网站源码
  • 网站服务器需要多大设计网站公司开发
  • asp 网站权限设计做网站业务员