spring boot thymeleaf 熱部署
在使用spring boot 開發的時候,使用了Thymeleaf 作為前端的模板開發,發現在調試過程中,改動了Thymeleaf模板后,需要重新啟動下項目,才可以立即生效
解決辦法:
ctrl+shift+f9
http://www.oschina.net/question/779083_2148086
spring boot推薦支持,因為spring boot是快速開發,而thymeleaf又是原型即頁面,所以從理念是接近的
單純從效率上看,沒有什么優勢,而且用這種測試也不太准
thymeleaf 的首次渲染比Beetl差的是數量級,后續的持續渲染,3.0版本是有很大提升的,也和Beetl也差不多
優勢是 html 的顯示優勢 前后端可以很好的分離,要是有很多的頁面拆分(include 的部分)優勢也不是很明顯了
是的,基本上都會抽出一些公用模版,所以這種優勢並不明顯,像引入的js,css
如果配置了HttpMessageConverter,然后在@ResponseBody的接口的返回值使用JSON.toJSONString()轉換過,輸出的結果就會有以下提示
解決辦法:接口直接返回對象,Spring會調用已經配置的HttpMessageConverter將對象轉換成json字符串
另外一個解決地思路:http://blog.csdn.net/u010161082/article/details/46618947
HttpMessageConvert配置示例:
<bean id="fastJsonHttpMessageConverter" class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> <value>application/json;charset=UTF-8</value> </list> </property> <property name="fastJsonConfig"> <bean class="com.alibaba.fastjson.support.config.FastJsonConfig"> <property name="features"> <list> <value>AllowArbitraryCommas</value> <value>AllowUnQuotedFieldNames</value> <value>DisableCircularReferenceDetect</value> </list> </property> <property name="dateFormat" value="yyyy-MM-dd HH:mm:ss"></property> </bean> </property> </bean>
http://blog.csdn.net/my_god_sky/article/details/53385246
<?xml version="1.0" encoding="UTF-8"?> <!-- 注意!SpringMVC的配置文件使用的是mvc命名空間 --> <beans:beans xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns="http://www.springframework.org/schema/mvc" xmlns:task="http://www.springframework.org/schema/task" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> <context:annotation-config/> <context:component-scan base-package="com.mkyong.common.controller" /> <annotation-driven> <message-converters register-defaults="true"> <!-- @ResponseBody亂碼問題,將StringHttpMessageConverter的默認編碼設為UTF-8 --> <beans:bean class="org.springframework.http.converter.StringHttpMessageConverter"> <beans:constructor-arg value="UTF-8"/> </beans:bean> <!-- 配置Fastjson支持 --> <beans:bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter"> <beans:property name="charset" value="UTF-8"/> <beans:property name="supportedMediaTypes"> <beans:list> <beans:value>application/json</beans:value> <beans:value>text/html;charset=UTF-8</beans:value> </beans:list> </beans:property> <beans:property name="features"> <beans:list> <beans:value>WriteMapNullValue</beans:value> <beans:value>QuoteFieldNames</beans:value> <beans:value>WriteDateUseDateFormat</beans:value> <beans:value>WriteEnumUsingToString</beans:value> </beans:list> </beans:property> </beans:bean> </message-converters> </annotation-driven> <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <beans:property name="prefix" value="/WEB-INF/"/> <beans:property name="suffix" value=".jsp"/> </beans:bean> </beans:beans>
http://www.cnblogs.com/sunp823/p/5601397.html