Spring boot整合jsp和tiles模板示例

首先贴上我的pox.xml文件,有详细的支持注释说明



	4.0.0
	demo
	1.0.1-SNAPSHOT
	demo
	
		
			nexus
			local private nexus
			http://maven.oschina.net/content/groups/public/
		
		
			spring-maven-release
			Spring Maven Release Repository
			http://maven.springframework.org/release
		
		
			spring-maven-milestone
			Spring Maven Milestone Repository
			http://maven.springframework.org/milestone
		
		
			mynexus
			my internal repository
			http://116.236.223.116:8082/nexus/content/groups/public/
		
	
	
		org.springframework.boot
		spring-boot-starter-parent
		1.3.0.RELEASE
		 
	
	
		UTF-8
		1.7
	
	
		
			org.springframework.boot
			spring-boot-starter
			
				
					org.springframework.boot
					spring-boot-starter-logging
				
			
		
		
		
			org.springframework.boot
			spring-boot-starter-data-jpa
			
				
					jcl-over-slf4j
					org.slf4j
				
			
		
		
			mysql
			mysql-connector-java
		
		
			commons-dbcp
			commons-dbcp
		
		
		
			org.springframework.boot
			spring-boot-starter-test
			test
			
				
					org.springframework.boot
					spring-boot-starter-logging
				
			
		
		
			com.github.sgroschupf
			zkclient
			0.1
		
		
			com.xr
			xuri-rpc-api
			1.0.1-SNAPSHOT
		
		
		
			org.apache.tiles
			tiles-jsp
			3.0.5
		
		
		
			javax.servlet
			jstl
		
		
		
			org.apache.tomcat.embed
			tomcat-embed-jasper
			provided
		
		
		
			org.springframework.mobile
			spring-mobile-device
		
		
			org.json
			json
		
	
	
		
			
			
				org.springframework.boot
				spring-boot-maven-plugin
				
					
						
							repackage
						
					
				
			
			
			
				org.apache.maven.plugins
				maven-surefire-plugin
				
					true
				
			
		
	
	war
 

在application.properties文件中需要加入配置如下

spring.mvc.view.prefix=/WEB-INF/jsp/ spring.mvc.view.suffix=.jsp

1.接下来我们写一个titles支持的模板jsp

<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>

	
		<tiles:getAsString name="title" />
	
	
		
		 
		
		
		
		
	

2.现在可以写一个整合titles的配置文件了tiles.xml




	
	
		
		
		
		
	
				
	
		
	

 3.最后我们需要加载titles.xml文件

@Configuration
public class ConfigurationForTiles {
    @Bean
    public TilesConfigurer tilesConfigurer() {
        final TilesConfigurer configurer = new TilesConfigurer();
        configurer.setDefinitions(new String[] { "WEB-INF/jsp/tiles.xml" });
        configurer.setCheckRefresh(true);
        return configurer;
    }
    @Bean
    public TilesViewResolver tilesViewResolver() {
        final TilesViewResolver resolver = new TilesViewResolver();
        resolver.setViewClass(TilesView.class);
        return resolver;
    }
}

以上就是Spring boot整合jsp和tiles模板示例的详细内容,更多关于Spring boot整合jsp和tiles模板的资料请关注脚本之家其它相关文章!

你可能感兴趣的:(Spring boot整合jsp和tiles模板示例)