thymeleaf

Thymeleaf dynamic form action url

…衆ロ難τιáo~ 提交于 2020-04-17 20:28:14
问题 <thymeleaf.version>3.0.9.RELEASE</thymeleaf.version> <thymeleaf-layout-dialect.version>2.2.2</thymeleaf-layout-dialect.version> Springboot How to construct expression for th:action "action url" in form? Url depends on "name" variable. I'm trying like this, but it's not working: <form method="get" th:action="@{'/' + {baseUrl}(baseUrl=${#strings.isEmpty(name) ? '' : 'user/find/'})}"> <input type="text" th:value="${name}"/> <button type="submit">Find</button> <button type="button" th:classappend

Thymeleaf dynamic form action url

你。 提交于 2020-04-17 20:25:33
问题 <thymeleaf.version>3.0.9.RELEASE</thymeleaf.version> <thymeleaf-layout-dialect.version>2.2.2</thymeleaf-layout-dialect.version> Springboot How to construct expression for th:action "action url" in form? Url depends on "name" variable. I'm trying like this, but it's not working: <form method="get" th:action="@{'/' + {baseUrl}(baseUrl=${#strings.isEmpty(name) ? '' : 'user/find/'})}"> <input type="text" th:value="${name}"/> <button type="submit">Find</button> <button type="button" th:classappend

知道Spring 和 Spring Boot 之间到底有啥区别? 这是差距

孤街浪徒 提交于 2020-04-17 18:59:22
分享分享自己收藏的学习资料,有需要的朋友可以找我获取 根据自身面试经历整理以及不断收集的(珍藏版) 【推荐】2020年最新Java电子书集合.pdf(吐血整理) >>> https://www.cnblogs.com/xiaogeng88/p/12692306.html 相信很多小伙伴和我一样,常用Spring 和Spring Boot 但是就是没有研究二者之间到底有什么区别? 今天就来大揭秘 ↓ 概述 对于 Spring和 SpringBoot到底有什么区别,我听到了很多答案,刚开始迈入学习 SpringBoot的我当时也是一头雾水,随着经验的积累、我慢慢理解了这两个框架到底有什么区别,相信对于用了 SpringBoot很久的同学来说,还不是很理解 SpringBoot到底和 Spring有什么区别,看完文章中的比较,或许你有了不同的答案和看法! 什么是Spring 作为 Java开发人员,大家都 Spring都不陌生,简而言之, Spring框架为开发 Java应用程序提供了全面的基础架构支持。它包含一些很好的功能,如依赖注入和开箱即用的模块,如:SpringJDBC、SpringMVC、SpringSecurity、SpringAOP、SpringORM、SpringTest,这些模块缩短应用程序的开发时间,提高了应用开发的效率例如,在 JavaWeb开发的早期阶段

更改Web根目录

微笑、不失礼 提交于 2020-04-16 16:48:38
【推荐阅读】微服务还能火多久?>>> 配置缓存 默认情况下,静态处理程序将设置缓存标头以使浏览器能够有效地缓存文件。 Vert.x的Web设置标题 cache-control , last-modified 和 date 。 cache-control max-age=86400 默认设置为。这相当于一天。 setMaxAgeSeconds 如果需要,可以配置它 。 如果浏览器发送带有 if-modified-since 标头的GET或HEAD请求,并且该资源自该日期起未被修改, 304 则返回状态,告知浏览器使用其本地缓存的资源。 如果不需要处理缓存头,则可以禁用它 setCachingEnabled 。 启用缓存处理后,Vert.x-Web将缓存内存中资源的最后修改日期,这样可以避免磁盘命中每次都检查实际的上次修改日期。 缓存中的条目具有到期时间,在此之后,将再次检查磁盘上的文件并更新缓存条目。 如果您知道您的文件永远不会在磁盘上更改,那么缓存条目将永远不会过期。这是默认值。 如果您知道在服务器运行时您的文件可能在磁盘上发生更改,那么您可以将只读文件设置为false setFilesReadOnly 。 要在任何时候启用可以在内存中缓存的最大条目数,您可以使用 setMaxCacheSize 。 要配置可以使用的缓存条目的到期时间 setCacheEntryTimeout 。

thymeleaf中使用javascript中的[[]]的3种处理方式

自闭症网瘾萝莉.ら 提交于 2020-04-09 04:54:13
thymeleaf中使用javascript中的[[]]的处理方式 1: 使用 CDATA 模式 /* <![CDATA[ */ 和 /* ]]> */ 就 OK 了 <script th:inline='javascript'> /* <![CDATA[ */ /* ]]> */ </script> 2:把 [[ ]] 分开写 ,写成 [ [ ] ] 把连续2个左中括号和右中括号之间添加空格 cols: [ [ {type: 'numbers'}, {field: 'authorityName', minWidth: 200, title: '权限名称'}, {field: 'authority', title: '权限标识'} ] ] 3: 使用th:inline='none'内联 th:inline他取值又3个,text, javascript,none 这里需要取th:inline='none' <script th:inline="none"> </script> 来源: oschina 链接: https://my.oschina.net/lenglingx/blog/3225363

Spring Boot整合Thymeleaf视图层

北战南征 提交于 2020-04-08 03:24:59
目录 Spring Boot整合Thymeleaf Spring Boot整合Thymeleaf 的项目步骤 Thymeleaf 语法详解 Spring Boot整合Thymeleaf Spring Boot整合Thymeleaf(Spring Boot官方推荐的视图层技术) Thymeleaf特点:thymeleaf通过特定的语法对html的标记进行渲染。 Spring Boot整合Thymeleaf 的项目步骤 创建Thymeleaf的项目(maven project的jar类型的spring boot项目) 打开pom.xml文件,添加启动器坐标 代码: <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.4.RELEASE</version> </parent> <dependencies> <!-- spring boot的web启动器 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!--

Springboot根据url后缀返回json或者xml或者html

杀马特。学长 韩版系。学妹 提交于 2020-04-06 18:17:56
Springboot根据url后缀返回json或者xml或者html Springboot根据url后缀. 返回json或者xml; 根据后缀名称返回html。 作者:liuren 版权声明:本文为原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。 初始化Springboot项目 一、首先引入的pom.xml文件包 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.4.RELEASE</version>

SSO单点登录

走远了吗. 提交于 2020-04-06 07:35:15
前言:今天刚学完B站up主“楠哥教你学Java”前些日子的一个直播教学,通过录播跟着把代码敲了一遍,整理了一下。前半部分取自楠哥的笔记,后部分代码和思维导图自己归纳总结,代码细节今天是撸不完了,明后天在多研究几遍一些细节 单点登录 什么是单点登录:一处登录,处处登录,一处登出,处处登出。 用户只需要登录一次就可以访问所有相互信任的应用系统。 SSO Single Sign On 单点登录 企业业务整合解决方案 一票通 SSO 原理 当用户第一次访问淘宝的时候,因为还没有登录,会被引导到认证中心进行登录。 根据用户提供的登录信息,认证系统进行身份验证,如果通过,则登录成功,并返回给用户一个认证的凭据(token)。 当用户访问天猫时,就会将这个 token 带上,作为自己认证的凭据。 应用系统接收到请求后会把 token 送到认证中心进行校验,检查 token 的合法性。 如果通过校验,用户就可以在不用再次登录的情况下访问天猫了。 SSO 实现技术 Cookie 单点登录 使用 Cookie 作为媒介,存放用户凭证。 用户登录淘宝之后,返回一个 token,存入客户端的 Cookie 中,当用户访问天猫的时候,会自动带上 Cookie,这样 token 又传给了认证中心,进行校验。 分布式 Session 1、用户第一次登录时,将会话信息,写入分布式 Session。 2

java - thymeleaf 邮件模板

心不动则不痛 提交于 2020-04-04 10:33:03
  使用 thymeleaf 制作邮件模版还是很简单的,先推荐官方文档: https://www.thymeleaf.org/doc/articles/springmail.html   不过,该文档没给出项目结构以及文件路径,所以可能有点不知道该怎么放置比较好,但文档里给出了github上的示例: https://github.com/thymeleaf/thymeleafexamples-springmail   我是复制粘贴的,有小部分用不上,但其实基本上可以git下来用,因为用上的还是大部分。   需要注意的是,文档示例不是 spring boot 的,而是 MVC 的。spring boot + thymeleaf 查找模板默认从 ../resources/templates/ 下找,而且.txt 文件模板必须要加上后缀,不然默认找 .html,所以如过用 txt 模板不加后缀会找不到,这些是文档中没说的,还有一点就是代码不需要任何 config 部分,首先是spring boot 帮你做了大部分事情,然后还有一小部分只需要加到 application.properties 文件中就可以了。   关于 pom.xml 其实只用加上下面两个就可以了: <dependency> <groupId>commons-io</groupId> <artifactId>commons

SpringBoot 之 静态资源路径、显示首页

时光怂恿深爱的人放手 提交于 2020-03-30 22:29:54
静态资源路径 静态资源支持放在以下路径中,访问优先级从上到下: classpath:/META-INF/resources/ classpath:/resources/ classpath:/static/ # 默认路径 classpath:/public/ 其中 classpath 为 src/main/resources 目录。 请求地址为: http://localhost:8080/xx.js 首页 文件位置: classpath:/static/favicon.ico classpath:/templates/index.html 导入 thymeleaf 模板引擎依赖: <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.thymeleaf</groupId> <artifactId>thymeleaf-spring5</artifactId> </dependency> <dependency> <groupId>org.thymeleaf.extras</groupId> <artifactId