springboot: 使web项目支持jsp
1.springboot为什么不推荐使用jsp?
参考地址:https://spring.io/blog/2012/10/30/spring-mvc-from-jsp-and-tiles-to-thymeleaf

2.使用freemark模板引擎有何优势
参考地址:http://blog.csdn.net/qq897958555/article/details/53560655

3.代码实现
1).pom.xml
<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.lf</groupId>
<artifactId>SpringBootInJsp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging> <!-- 继承 spring-boot-starter-paren -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
</parent>
<dependencies>
<!-- SpringBoot 核心组件 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 添加jsp支持 -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
</dependencies>
</project>
2).IndexController.java
package com.lf.controller; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; @Controller
@EnableAutoConfiguration
public class IndexController {
@RequestMapping("index")
public String index(){
return "index";
} public static void main(String[] args) {
SpringApplication.run(IndexController.class, args);
}
}
3).index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>SpringBoot集成JSP!</h1>
</body>
</html>
4).测试

springboot: 使web项目支持jsp的更多相关文章
- springboot 整合 web 项目找不到 jsp 文件
今天遇到一个问题,就是使用springboot整合web项目的时候,怎么都访问不到 \webapp\WEB-INF\jsp\index.jsp 页面.这个问题搞了半天,试了各种方式.最后是因为在启动的 ...
- 基于springboot的web项目最佳实践
springboot 可以说是现在做javaweb开发最火的技术,我在基于springboot搭建项目的过程中,踩过不少坑,发现整合框架时并非仅仅引入starter 那么简单. 要做到简单,易用,扩展 ...
- springBoot 搭建web项目(前后端分离,附项目源代码地址)
springBoot 搭建web项目(前后端分离,附项目源代码地址) 概述 该项目包含springBoot-example-ui 和 springBoot-example,分别为前端与后端,前后端 ...
- 使用Eclipse开发Web项目(JSP)——简单登录、无sql
1.使用Eclipse开发Web项目(JSP) tomcat 2.在Eclipse中创建的Web项目: 浏览器可以直接访问webContent中的文件 例如http://localhost:8080/ ...
- Springboot开发web项目
当前,Spring毫无疑问已经成为java后台对象管理标准框架,除了通过IOC能够管理我们的自定义对象的生命周期之外还提供了众多功能繁复的可配置功能模块.但同时带来了复杂的配置项,这对初学者而言简直是 ...
- 手把手的SpringBoot教程,SpringBoot创建web项目(一)
1.引子 大家好,在接下里的半个多小时,我会给大家详细的介绍SpringBoot的基本使用,相信学完这门课程以后,你会对SpringBoot有一个清晰的认识,并且能够运用这门比较新颖的技术开发一些小程 ...
- Eclipse下Maven新建Web项目index.jsp报错完美解决(war包)
Eclipse下Maven新建Web项目步骤 1. 2. 3. 4. 5. 问题描述 最近用eclipse新建了一个maven项目,结果刚新建完成index.jsp页面就报错了,先把错误信息贴出来看看 ...
- springboot搭建web项目与使用配置文件
目录 一.准备工作 二.创建基础web项目 1. maven配置 2.创建maven项目.配置pom.xml为web基础项目 3.编写启动类 4.使用maven打包 5.使用命令java -jar x ...
- 使用SpringBoot搭建Web项目
序言 从简入深的使用SpringBoot搭建一个Web项目,同时也包括一些小的问题.第一篇博文是以较为简单的方式完成一个可以连接数据库的Springboot web程序.之前自己学习的时候看网上的教程 ...
随机推荐
- flask学习(四):debug模式
一. 设置debug模式 1. flask 1.0之前 在app.run()中传入一个关键字参数debug,app.run(debug=True),就设置当前项目为debug模式 2. flask 1 ...
- Ubuntu 下Python 环境问题
问题描述: 原先使用Anaconda环境,若卸载后仍不能恢复到系统默认的Python环境. 解决方案: shell 寻找缓存路径,python的扩展/home/tom/anaconda/bin/pyt ...
- Django 前后台的数据传递示列
Django 前后台的数据传递的方法 Django 从后台往前台传递数据时有多种方法可以实现. 最简单的后台是这样的: ? 1 2 3 4 from django.shortcuts import r ...
- Highcharts 树状图(Treemap)
Highcharts 树状图(Treemap) 树状图 series 配置 设置 series 的 type 属性为 treemap ,series.type 描述了数据列类型.默认值为 " ...
- Sql server日期函数操作
1.获取前一小时内的数据:DATEADD(HOUR,-1,GETDATE()),将"HOUR"替换成DAY,Month,YEAR就是前一天,前一月,前一年 2.获取日期部分,格式为 ...
- Linux(CentOS 7) 新增或修改 SSH默认端口
通过ssh连接到服务器,登录root用户 执行命令编辑sshd配置文件 vi /etc/ssh/sshd_config 找到这一行 # Port 去除#号,修改22 为你想要的端口 重启sshd服务 ...
- LabVIEW中使用GPU进行高性能计算
项目中需要使用LabVIEW控制NI FPGA board产生控制信号等,使用GPU对采集的数据进行高性能计算,因此方案之一是用Visual Studio设计基于CUDA的GPU并行计算算法代码,然后 ...
- WIFI 基础知识
转载自:wifi基本知识 如侵犯您的版权,请联系:2378264731@qq.com 1. IE802.11简介 标准号 IEEE 802.11b IEEE 802.11a IEEE 802.11g ...
- 2018.11.13 N4010A 通信设置
设置电脑之IP地址及Subnet mask. IP address: 192.168.1.2 Subnet mask: 255.255.255.0, 其它选项为默认. 然后点击OK ...
- Xss测试
<Script>alert(“XSS attack available!”);</Script>