springboot 运行jar 跳转jsp页面
pom.xml
添加
- <!-- tomcat支持 -->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-tomcat</artifactId>
- <scope>provided</scope>
- </dependency>
- <!---解析jsp--->
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-jasper</artifactId>
- <scope>provided</scope>
- </dependency>
- <!---解析jstl--->
- <dependency>
- <groupId>jstl</groupId>
- <artifactId>jstl</artifactId>
- <version>${jstl.version}</version>
- </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标签
- <build>
- <plugins>
- <!-- spring dev -->
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <version>1.4.2.RELEASE</version>
- <configuration>
- <mainClass>com.njhzlh.SpringBootRedisSessionApplication</mainClass>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>repackage</goal>
- </goals>
- </execution>
- </executions>
- <dependencies>
- <!-- spring热部署 -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>springloaded</artifactId>
- <version>1.2.6.RELEASE</version>
- </dependency>
- </dependencies>
- </plugin>
- <!-- 忽略无web.xml警告 -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <failOnMissingWebXml>false</failOnMissingWebXml>
- </configuration>
- </plugin>
- </plugins>
- <resources>
- <!-- 打包时将jsp文件拷贝到META-INF目录下 -->
- <resource>
- <!-- 指定resources插件处理哪个目录下的资源文件 -->
- <directory>src/main/webapp</directory>
- <!--注意此次必须要放在此目录下才能被访问到 -->
- <targetPath>META-INF/resources</targetPath>
- <includes>
- <include>**/**</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <includes>
- <include>**/**</include>
- </includes>
- <filtering>false</filtering>
- </resource>
- </resources>
- </build>
完整的配置()
- <?xml version="1.0" encoding="UTF-8"?>
- <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.njhzlh</groupId>
- <artifactId>SpringBootRedisSession</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <packaging>jar</packaging>
- <name>SpringBootRedisSession</name>
- <description>Demo project for Spring Boot</description>
- <parent>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-parent</artifactId>
- <version>2.0.4.RELEASE</version>
- <relativePath/> <!-- lookup parent from repository -->
- </parent>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <java.version>1.8</java.version>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-data-redis</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.session</groupId>
- <artifactId>spring-session-data-redis</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
- <!-- tomcat支持 -->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-tomcat</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-jasper</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>jstl</groupId>
- <artifactId>jstl</artifactId>
- <version>${jstl.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <scope>test</scope>
- </dependency>
- <!-- 使用jsp必须要有这两个依赖 -->
- <!-- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jstl</artifactId>
- </dependency> -->
- </dependencies>
- <build>
- <plugins>
- <!-- spring dev -->
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <version>1.4.2.RELEASE</version>
- <configuration>
- <mainClass>com.njhzlh.SpringBootRedisSessionApplication</mainClass>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>repackage</goal>
- </goals>
- </execution>
- </executions>
- <dependencies>
- <!-- spring热部署 -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>springloaded</artifactId>
- <version>1.2.6.RELEASE</version>
- </dependency>
- </dependencies>
- </plugin>
- <!-- 忽略无web.xml警告 -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <failOnMissingWebXml>false</failOnMissingWebXml>
- </configuration>
- </plugin>
- </plugins>
- <resources>
- <!-- 打包时将jsp文件拷贝到META-INF目录下 -->
- <resource>
- <!-- 指定resources插件处理哪个目录下的资源文件 -->
- <directory>src/main/webapp</directory>
- <!--注意此次必须要放在此目录下才能被访问到 -->
- <targetPath>META-INF/resources</targetPath>
- <includes>
- <include>**/**</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <includes>
- <include>**/**</include>
- </includes>
- <filtering>false</filtering>
- </resource>
- </resources>
- </build>
- </project>
3 测试
- @Controller
- public class TestMVCController {
- @RequestMapping("/")
- public String index(HttpServletRequest request) {
- return "login";
- }
- }
访问 127.0.0.1:8080 成功跳转页面
springboot 运行jar 跳转jsp页面的更多相关文章
- springboot 2.0.8 跳转jsp页面
springboot项目创建教程 https://blog.csdn.net/q18771811872/article/details/88126835 springboot 2.0跳转 html教程 ...
- 分享url带中文参数,打开html操作完毕跳转jsp页面中文乱码解决
1.在app端分享参数组合时不对传递的url进行任何编码. 2.打开html页面时使用 escape函数对有中文的参数进行编码 escape(GetQueryString("paramete ...
- springboot跳转jsp页面
springboot支持jsp页面跳转 官方不推荐jsp的支持(jar包不支持jsp,jsp需要运行在servletContext中,war包需要运行在server服务器中如tomcat)官方推荐使用 ...
- 在idea 上springboot 1.5.6集成jsp页面
第一步:新建一个项目 推荐使用这个,默认下一步就好, 填写自己的信息,next, , 选择使用的功能,也可以新建好之后再pom.xml里手动添加, 选择项目存放地址,一个springboot的项目就建 ...
- springboot+jsp+mybatis项目实例(后台成功,但是无法跳转jsp页面,没有实体类的注解,看springboot+jsp第二弹相关配置,即可成功配置jsp)
SpringBoot是用来简化SpringMvc开发的项目,这里自然要整合mybatis等持久化框架! 先看看项目目录: 一.在pom.xml中配置依赖jar包:<project xmlns=& ...
- request.getRequestDispatcher跳转jsp页面失败
我在JS里面写了个Ajax,传值给控制器,然后利用request.getRequestDispatcher(),打算跳转至另外一个页面.但是没有跳转成功,运行之后没反应. 在网上搜了资料发现,利用aj ...
- springboot用controller跳转html页面
之前SSM框架,里面有webapps文件夹,用来存放前端页面和各种前端资源,现在SpringBoot中没有webapps文件夹,springboot结构如下: 第一.resourses下文件夹publ ...
- 18. 进livebos对象直接跳转jsp页面的做法
在网格脚本定义添加: window.onload=function(){ window.location.href='/plug-in/sinopec/contractManagement/h ...
- JFinal跳转jsp页面空白
eclipse工具中java的编译有的设置的是jre,而jsp是需要jdk来进行编译的 将这里改为jdk的就可以了
随机推荐
- knuth洗牌算法
首先来思考一个问题: 设计一个公平的洗牌算法 1. 看问题,洗牌,显然是一个随机算法了.随机算法还不简单?随机呗.把所有牌放到一个数组中,每次取两张牌交换位置,随机 k 次即可. 如果你的答案是这样, ...
- 【机器学习之二】python开发spark案例
环境 spark-1.6 python3.5 一.wordcount # -*- coding:utf-8 -*- ''' Created on 2019年5月13日 @author: Adminis ...
- 【Python学习之九】模块
环境 虚拟机:VMware 10 Linux版本:CentOS-6.5-x86_64 客户端:Xshell4 FTP:Xftp4 python3.6 一.模块的使用和安装模块和C语言中的头文件以及Ja ...
- [ARM-Linux开发]linux 里 /etc/passwd 、/etc/shadow和/etc/group 文件内容解释
linux 里 /etc/passwd ./etc/shadow和/etc/group 文件内容解释 一./etc/passwd 是用户数据库,其中的域给出了用户名.加密口令和用户的其他信息 /etc ...
- 【视频开发】【电子电路技术】监控球机PTZ的功能介绍
主要分模拟球机和网络球机两种 1.模拟球机 模拟球机除了需要接电源外,还需要接视频线和485控制线才能实现视频传输和云台控制,并且需要配置波特率,地址位和协议. 升级版:HDTVI球机 ① 同轴视控. ...
- C++ 读取一个文件下所有文件的文件名
Windows: #include<iostream> #include<string> #include <io.h> void readFileNameInDi ...
- 【LEETCODE】42、922. Sort Array By Parity II
package y2019.Algorithm.array; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array * ...
- int and Integer
int和Integer的区别 1.Integer是int的包装类,int则是java的一种基本数据类型 2.Integer变量必须实例化后才能使用,而int变量不需要 3.Integer实际是对象的引 ...
- quartz2.3.0(九)job任务监听器,监听任务执行前、后、取消手动处理方法
job1任务类 package org.quartz.examples.example9; import java.util.Date; import org.quartz.Job; import o ...
- Python之TensorFlow的变量收集、自定义命令参数、矩阵运算、梯度下降-4
一.TensorFlow为什么要存在变量收集的过程,主要目的就是把训练过程中的数据,比如loss.权重.偏置等数据通过图形展示的方式呈现在开发者的眼前. 自定义参数:自定义参数,主要是通过Python ...