pom.xml

添加

  1. <!-- tomcat支持 -->
  2. <dependency>
  3. <groupId>org.springframework.boot</groupId>
  4. <artifactId>spring-boot-starter-tomcat</artifactId>
  5. <scope>provided</scope>
  6. </dependency>
  7. <!---解析jsp--->
  8. <dependency>
  9. <groupId>org.apache.tomcat.embed</groupId>
  10. <artifactId>tomcat-embed-jasper</artifactId>
  11. <scope>provided</scope>
  12. </dependency>
  13. <!---解析jstl--->
  14. <dependency>
  15. <groupId>jstl</groupId>
  16. <artifactId>jstl</artifactId>
  17. <version>${jstl.version}</version>
  18. </dependency>

2 配置文件添加 默认是访问 src/main/webapp  文件夹   如果src/main 没有就新建webapp文件夹

spring.mvc.view.prefix=/WEB-INF/jsp/    # src/main/webapp/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp

3 修改pom.xml build标签

  1. <build>
  2. <plugins>
  3. <!-- spring dev -->
  4. <plugin>
  5. <groupId>org.springframework.boot</groupId>
  6. <artifactId>spring-boot-maven-plugin</artifactId>
  7. <version>1.4.2.RELEASE</version>
  8. <configuration>
  9. <mainClass>com.njhzlh.SpringBootRedisSessionApplication</mainClass>
  10. </configuration>
  11. <executions>
  12. <execution>
  13. <goals>
  14. <goal>repackage</goal>
  15. </goals>
  16. </execution>
  17. </executions>
  18. <dependencies>
  19. <!-- spring热部署 -->
  20. <dependency>
  21. <groupId>org.springframework</groupId>
  22. <artifactId>springloaded</artifactId>
  23. <version>1.2.6.RELEASE</version>
  24. </dependency>
  25. </dependencies>
  26. </plugin>
  27. <!-- 忽略无web.xml警告 -->
  28. <plugin>
  29. <groupId>org.apache.maven.plugins</groupId>
  30. <artifactId>maven-war-plugin</artifactId>
  31. <configuration>
  32. <failOnMissingWebXml>false</failOnMissingWebXml>
  33. </configuration>
  34. </plugin>
  35. </plugins>
  36. <resources>
  37. <!-- 打包时将jsp文件拷贝到META-INF目录下 -->
  38. <resource>
  39. <!-- 指定resources插件处理哪个目录下的资源文件 -->
  40. <directory>src/main/webapp</directory>
  41. <!--注意此次必须要放在此目录下才能被访问到 -->
  42. <targetPath>META-INF/resources</targetPath>
  43. <includes>
  44. <include>**/**</include>
  45. </includes>
  46. </resource>
  47. <resource>
  48. <directory>src/main/resources</directory>
  49. <includes>
  50. <include>**/**</include>
  51. </includes>
  52. <filtering>false</filtering>
  53. </resource>
  54.  
  55. </resources>
  56. </build>

完整的配置()

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5.  
  6. <groupId>com.njhzlh</groupId>
  7. <artifactId>SpringBootRedisSession</artifactId>
  8. <version>0.0.1-SNAPSHOT</version>
  9. <packaging>jar</packaging>
  10.  
  11. <name>SpringBootRedisSession</name>
  12. <description>Demo project for Spring Boot</description>
  13.  
  14. <parent>
  15. <groupId>org.springframework.boot</groupId>
  16. <artifactId>spring-boot-starter-parent</artifactId>
  17. <version>2.0.4.RELEASE</version>
  18. <relativePath/> <!-- lookup parent from repository -->
  19. </parent>
  20.  
  21. <properties>
  22. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  23. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  24. <java.version>1.8</java.version>
  25. </properties>
  26.  
  27. <dependencies>
  28. <dependency>
  29. <groupId>org.springframework.boot</groupId>
  30. <artifactId>spring-boot-starter-data-redis</artifactId>
  31. </dependency>
  32.  
  33. <dependency>
  34. <groupId>org.springframework.session</groupId>
  35. <artifactId>spring-session-data-redis</artifactId>
  36. </dependency>
  37.  
  38. <dependency>
  39. <groupId>org.springframework.boot</groupId>
  40. <artifactId>spring-boot-starter-web</artifactId>
  41. </dependency>
  42. <!-- tomcat支持 -->
  43. <dependency>
  44. <groupId>org.springframework.boot</groupId>
  45. <artifactId>spring-boot-starter-tomcat</artifactId>
  46. <scope>provided</scope>
  47. </dependency>
  48. <dependency>
  49. <groupId>org.apache.tomcat.embed</groupId>
  50. <artifactId>tomcat-embed-jasper</artifactId>
  51. <scope>provided</scope>
  52. </dependency>
  53.  
  54. <dependency>
  55. <groupId>jstl</groupId>
  56. <artifactId>jstl</artifactId>
  57. <version>${jstl.version}</version>
  58. </dependency>
  59.  
  60. <dependency>
  61. <groupId>org.springframework.boot</groupId>
  62. <artifactId>spring-boot-starter-test</artifactId>
  63. <scope>test</scope>
  64. </dependency>
  65.  
  66. <!-- 使用jsp必须要有这两个依赖 -->
  67. <!-- <dependency>
  68. <groupId>javax.servlet</groupId>
  69. <artifactId>jstl</artifactId>
  70. </dependency> -->
  71.  
  72. </dependencies>
  73.  
  74. <build>
  75. <plugins>
  76. <!-- spring dev -->
  77. <plugin>
  78. <groupId>org.springframework.boot</groupId>
  79. <artifactId>spring-boot-maven-plugin</artifactId>
  80. <version>1.4.2.RELEASE</version>
  81. <configuration>
  82. <mainClass>com.njhzlh.SpringBootRedisSessionApplication</mainClass>
  83. </configuration>
  84. <executions>
  85. <execution>
  86. <goals>
  87. <goal>repackage</goal>
  88. </goals>
  89. </execution>
  90. </executions>
  91. <dependencies>
  92. <!-- spring热部署 -->
  93. <dependency>
  94. <groupId>org.springframework</groupId>
  95. <artifactId>springloaded</artifactId>
  96. <version>1.2.6.RELEASE</version>
  97. </dependency>
  98. </dependencies>
  99. </plugin>
  100. <!-- 忽略无web.xml警告 -->
  101. <plugin>
  102. <groupId>org.apache.maven.plugins</groupId>
  103. <artifactId>maven-war-plugin</artifactId>
  104. <configuration>
  105. <failOnMissingWebXml>false</failOnMissingWebXml>
  106. </configuration>
  107. </plugin>
  108. </plugins>
  109. <resources>
  110. <!-- 打包时将jsp文件拷贝到META-INF目录下 -->
  111. <resource>
  112. <!-- 指定resources插件处理哪个目录下的资源文件 -->
  113. <directory>src/main/webapp</directory>
  114. <!--注意此次必须要放在此目录下才能被访问到 -->
  115. <targetPath>META-INF/resources</targetPath>
  116. <includes>
  117. <include>**/**</include>
  118. </includes>
  119. </resource>
  120. <resource>
  121. <directory>src/main/resources</directory>
  122. <includes>
  123. <include>**/**</include>
  124. </includes>
  125. <filtering>false</filtering>
  126. </resource>
  127.  
  128. </resources>
  129. </build>
  130.  
  131. </project>

3 测试

  1. @Controller
  2. public class TestMVCController {
  3. @RequestMapping("/")
  4. public String index(HttpServletRequest request) {
  5. return "login";
  6. }
  7. }

访问 127.0.0.1:8080  成功跳转页面

springboot 运行jar 跳转jsp页面的更多相关文章

  1. springboot 2.0.8 跳转jsp页面

    springboot项目创建教程 https://blog.csdn.net/q18771811872/article/details/88126835 springboot 2.0跳转 html教程 ...

  2. 分享url带中文参数,打开html操作完毕跳转jsp页面中文乱码解决

    1.在app端分享参数组合时不对传递的url进行任何编码. 2.打开html页面时使用 escape函数对有中文的参数进行编码 escape(GetQueryString("paramete ...

  3. springboot跳转jsp页面

    springboot支持jsp页面跳转 官方不推荐jsp的支持(jar包不支持jsp,jsp需要运行在servletContext中,war包需要运行在server服务器中如tomcat)官方推荐使用 ...

  4. 在idea 上springboot 1.5.6集成jsp页面

    第一步:新建一个项目 推荐使用这个,默认下一步就好, 填写自己的信息,next, , 选择使用的功能,也可以新建好之后再pom.xml里手动添加, 选择项目存放地址,一个springboot的项目就建 ...

  5. springboot+jsp+mybatis项目实例(后台成功,但是无法跳转jsp页面,没有实体类的注解,看springboot+jsp第二弹相关配置,即可成功配置jsp)

    SpringBoot是用来简化SpringMvc开发的项目,这里自然要整合mybatis等持久化框架! 先看看项目目录: 一.在pom.xml中配置依赖jar包:<project xmlns=& ...

  6. request.getRequestDispatcher跳转jsp页面失败

    我在JS里面写了个Ajax,传值给控制器,然后利用request.getRequestDispatcher(),打算跳转至另外一个页面.但是没有跳转成功,运行之后没反应. 在网上搜了资料发现,利用aj ...

  7. springboot用controller跳转html页面

    之前SSM框架,里面有webapps文件夹,用来存放前端页面和各种前端资源,现在SpringBoot中没有webapps文件夹,springboot结构如下: 第一.resourses下文件夹publ ...

  8. 18. 进livebos对象直接跳转jsp页面的做法

    在网格脚本定义添加: window.onload=function(){     window.location.href='/plug-in/sinopec/contractManagement/h ...

  9. JFinal跳转jsp页面空白

    eclipse工具中java的编译有的设置的是jre,而jsp是需要jdk来进行编译的 将这里改为jdk的就可以了

随机推荐

  1. knuth洗牌算法

    首先来思考一个问题: 设计一个公平的洗牌算法 1. 看问题,洗牌,显然是一个随机算法了.随机算法还不简单?随机呗.把所有牌放到一个数组中,每次取两张牌交换位置,随机 k 次即可. 如果你的答案是这样, ...

  2. 【机器学习之二】python开发spark案例

    环境 spark-1.6 python3.5 一.wordcount # -*- coding:utf-8 -*- ''' Created on 2019年5月13日 @author: Adminis ...

  3. 【Python学习之九】模块

    环境 虚拟机:VMware 10 Linux版本:CentOS-6.5-x86_64 客户端:Xshell4 FTP:Xftp4 python3.6 一.模块的使用和安装模块和C语言中的头文件以及Ja ...

  4. [ARM-Linux开发]linux 里 /etc/passwd 、/etc/shadow和/etc/group 文件内容解释

    linux 里 /etc/passwd ./etc/shadow和/etc/group 文件内容解释 一./etc/passwd 是用户数据库,其中的域给出了用户名.加密口令和用户的其他信息 /etc ...

  5. 【视频开发】【电子电路技术】监控球机PTZ的功能介绍

    主要分模拟球机和网络球机两种 1.模拟球机 模拟球机除了需要接电源外,还需要接视频线和485控制线才能实现视频传输和云台控制,并且需要配置波特率,地址位和协议. 升级版:HDTVI球机 ① 同轴视控. ...

  6. C++ 读取一个文件下所有文件的文件名

    Windows: #include<iostream> #include<string> #include <io.h> void readFileNameInDi ...

  7. 【LEETCODE】42、922. Sort Array By Parity II

    package y2019.Algorithm.array; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array * ...

  8. int and Integer

    int和Integer的区别 1.Integer是int的包装类,int则是java的一种基本数据类型 2.Integer变量必须实例化后才能使用,而int变量不需要 3.Integer实际是对象的引 ...

  9. quartz2.3.0(九)job任务监听器,监听任务执行前、后、取消手动处理方法

    job1任务类 package org.quartz.examples.example9; import java.util.Date; import org.quartz.Job; import o ...

  10. Python之TensorFlow的变量收集、自定义命令参数、矩阵运算、梯度下降-4

    一.TensorFlow为什么要存在变量收集的过程,主要目的就是把训练过程中的数据,比如loss.权重.偏置等数据通过图形展示的方式呈现在开发者的眼前. 自定义参数:自定义参数,主要是通过Python ...