当前位置 : 主页 > 编程语言 > c++ >

在Springboot中集成jsp

来源:互联网 收集:自由互联 发布时间:2021-06-30
总结.txt Springboot集成jsp步骤:1、在pom.xml中添加servlet-api,jstl,tomcat-embed-jasper依赖 javax.servlet javax.servlet-api provided jstl jstl 1.2 provided org.apache.tomcat.embed tomcat-embed-jasper provided 2、在applica
总结.txt
Springboot集成jsp
步骤:
	1、在pom.xml中添加servlet-api,jstl,tomcat-embed-jasper依赖
		
 
			
  
   javax.servlet
  
			
  
   javax.servlet-api
  
			
  
   provided
  
		
 
		
 
			
  
   jstl
  
			
  
   jstl
  
			
  
   1.2
  
			
  
   provided
  
		
 
		
 
			
  
   org.apache.tomcat.embed
  
			
  
   tomcat-embed-jasper
  
			
  
   provided
  
		
 
		
	2、在application.yml中添加mvc配置
		spring.mvc.view.prefix=/WEB-INF/jsp/ #页面默认前缀目录
		spring.mvc.view.suffix=.jsp #页面默认后缀
		
	3、在/WEB-INF/jsp/下新建controller返回的对应的jsp页面
	
问题:Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
原因:spring-boot-starter-tomcat下载包不完整
解决方案:删除后再update maven
application.yml
spring:
  mvc:
    view:
      prefix: /WEB-INF/jsp/ #页面默认前缀目录
      suffix: .jsp #页面默认后缀
pom.xml
 

 
	
  
   4.0.0
  

	
  
   org.com.cay.spring-boot
  
	
  
   spring-boot-jsp
  
	
  
   0.0.1-SNAPSHOT
  
	
  
   war
  

	
  
   spring-boot-jsp
  
	
  
   Demo project for Spring Boot
  

	
   
   
    org.springframework.boot
    
   
    spring-boot-starter-parent
    
   
    1.5.6.RELEASE
    
    
    
  

	
   
   
    UTF-8
    
   
    UTF-8
    
   
    1.8
    
  

	
   
    
    
     org.springframework.boot
     
    
     spring-boot-starter-web
     
    
    
    
     org.springframework.boot
     
    
     spring-boot-starter-tomcat
     
    
    
    
     org.springframework.boot
     
    
     spring-boot-starter-test
     
    
     test
     
    
    
    
     javax.servlet
     
    
     javax.servlet-api
     
    
     provided
     
    
    
    
     jstl
     
    
     jstl
     
    
     1.2
     
    
     provided
     
    
    
    
     org.apache.tomcat.embed
     
    
     tomcat-embed-jasper
     
    
     provided
     
    
  

	
   
    
     
     
      org.springframework.boot
      
     
      spring-boot-maven-plugin
      
     
    
  



 
网友评论