解决SpringBoot启动过后不能访问jsp页面的问题(超详细)
袁家小少爷 人气:11、首先看SSM(Spring+SpringBoot+Mybatis)的依赖
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.easyshop.springboot.web</groupId> <artifactId>easyshop</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.2.RELEASE</version> </parent> <dependencies> <!-- SpringBoot的Web启动器 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <https://img.qb5200.com/download-x/dependency> <!--切面--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> <https://img.qb5200.com/download-x/dependency> <!--cglib--> <dependency> <groupId>cglib</groupId> <artifactId>cglib-nodep</artifactId> <version>2.1_3</version> <https://img.qb5200.com/download-x/dependency> <!--日志--> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.2</version> <https://img.qb5200.com/download-x/dependency> <!-- MyBatis --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.3.0</version> <https://img.qb5200.com/download-x/dependency> <!-- mybatis和spring整合 1.2.2 --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.2.2</version> <https://img.qb5200.com/download-x/dependency> <!-- mysql --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.28</version> <https://img.qb5200.com/download-x/dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.10</version> <https://img.qb5200.com/download-x/dependency> <!-- JSP相关 --> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.2</version> <https://img.qb5200.com/download-x/dependency> <!-- SpringBoot事物管理器 自动配置 DataSourceTransactionManager --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> <https://img.qb5200.com/download-x/dependency> <!-- 解析JSP --> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <https://img.qb5200.com/download-x/dependency> <https://img.qb5200.com/download-x/dependencies> <build> <plugins> <!-- SpringBoot启动 --> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> <resources> <resource> <directory>src/main/java<https://img.qb5200.com/download-x/directory> <includes> <include>**/*.xml</include> <include>**/*.properties</include> </includes> <filtering>true</filtering> </resource> <resource> <directory>src/main/resources<https://img.qb5200.com/download-x/directory> <includes> <include>**/*.xml</include> <include>**/*.properties</include> </includes> <filtering>true</filtering> </resource> </resources> </build> </project>
2、看两种启动方式不同进行访问jsp页面
第一种,直接maven启动
可以直接访问jsp
第二种
写一个类来达到访问的目的
访问是一样的,这两种方法都可以选择,这是我百度了很久找出来的法子!可以解决springboor访问jsp的问题!
补充一下 这里的File里面的路径是webapp的绝对路径哦!
加载全部内容