Springboot-shiro chapter02 -- springboot webmvc jsp, springbootshiro
Introduction: This section mainly involves spring boot's support for jsp. Due to its infamiliarity with spring boot, it takes some detours.
Environment:
IDEA15 +
JDK1.8 +
Maven3 +
I. pom. xml resource dependency
Compared with chapter01, there are more dependent resources. Spring-webmvc, spring-boot-starter, and spring-boot-tomcat are not directly referenced in chapter01. Instead, spring-boot-starter-web resources are referenced.
We can see that spring-boot-starter-web contains resources of chapter01. to parse jsp resources, we need to introduce jsaper, compile the jsp file into a java file, and compile it into a class file. In this case, jvm can load the corresponding class file of jsp.
In addition, jstl (jsp standard tag library) resources are mainly JSP standard tag libraries, improving jsp development efficiency
Note: The <parent> node is used to indirectly depend on spring-boot-starter-parent. Otherwise, compilation exceptions may occur during compilation.
Ii. springboot Configuration
Set attributes related to the spring MVC view parser.
spring.mvc.view.prefix: /WEB-INF/jsp/spring.mvc.view.suffix: .jsp
Startclass differs from chapter01. SpringBootServletInitializer inherits this class to deploy the application to the servlet container.
@SpringBootApplication@ComponentScan(value="com.shujushow")public class Chapter02Application extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application){ return application.sources(Chapter02Application.class); } public static void main(String[] args) throws Exception{ SpringApplication.run(Chapter02Application.class, args); }}