美文网首页
Day07:环境配置

Day07:环境配置

作者: 宇宙超人喵学长 | 来源:发表于2017-07-19 13:39 被阅读0次

1、thymeleaf模板引擎

  • 命名空间:<html xmlns:th="http://www.thymeleaf.org">
  • 迭代:

<ul class="list-group"> <li class="list-group-item" th:each="person:${people}"> <span th:text="${person.name}"></span> <span th:text="${person.age}"></span> </li> </ul>

  • 判断对象是否为空:${not #lists.isEmpty(people)}
  • script中访问model的值:
    <script th:inline="javascript"> var single = [[${singlePerson}]]; console.log(single.name + "/" + single.age); </script>
  • html总访问model
    ${entity.properties} th:onclick='"getName(\" + ${person.name} + '\');'"

2、集成Spring MVC

  • 参数中传入Model,给Model添加attribute,即可返回对象及值

3、Web相关配置

  • Spring Boot自动配置:
    ViewResolver
    ContentNegotiatingViewResolber:代理给不同的ViewResolver来处理不同的View; BeanNameViewResolver:controller返回视图名,根据该resolver查找bean的名称为返回字符串的view来渲染视图

4、静态首页,index可以自动映射的路径

classpath:/META-INF/resources/index.html classpath:/resources/index.html classpath:/static/index.html classpath:/public/index.html

5、接管springboot的web配置

  • 完全控制:在@Configuration注解的配置类上,加上@EnableWebMvc注解实现
  • 增加配置:定义配置类并继承WebMvcConfigurerAdapter,不用注解,然后重写方法:

@Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/xx").setViewName("/xx"); }

6、Servlet容器配置

server.port= server.session-timeout= #用户会话session过期时间,以秒为单位 server.context-path= #配置访问路径,默认为/ server.tomcat.url-encoding= server.tomcat.compression= #tomcat是否开启压缩,默认关闭

7、SSL(secure sockets layer,网络套接层)

相关文章

网友评论

      本文标题:Day07:环境配置

      本文链接:https://www.haomeiwen.com/subject/kawkkxtx.html