SpringBoot02——A Simple SpringBoot Project&Hot Deployment
1.简单的Controller映射
1.新建一个controller包,包一定在启动器的下一层级

2.可以在application.properties中进行调整端口和context-path参数

server.servlet.context-path=/SpringBoot03
server.port=
3.MainController配置
package com.littlepage.controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; @Controller
@RequestMapping("/MainController")
public class MainController {
@RequestMapping("/list")
@ResponseBody
public String list() {
return "list";
}
}
这样可以直接进行访问localhost:8080/Spring03/MainController/list
@ResponseBody表示响应体,可以响应直接返回的值
4.返回一个list
@Controller
@RequestMapping("/MainController")
public class MainController {
@RequestMapping("/list")
@ResponseBody
public List<String> list() {
List<String> arr=new ArrayList<>();
arr.add("");
arr.add("");
arr.add("");
arr.add("");
return arr;
}
}

5.返回页面,在starter中进行添加thymeleaf引擎
@Controller
@RequestMapping("/MainController")
public class MainController {
@RequestMapping("/list")
public String list() {
return "list";
}
}

默认是html文件
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
HelloWorld!
</body>
</html>

2.thymeleaf模板的简单使用
@Controller
@RequestMapping("/MainController")
public class MainController {
@RequestMapping("/list")
public String list(ModelMap map) {
map.put("name", "steve");
map.put("age", );
return "list";
}
}

这个map处于Context域,所以我们可以通过html进行取用,thymeleaf会进行Controller过来进行渲染map
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<p th:text="${name}"></p>
</body>
</html>

3.热部署
1).SpringBoot自带的devtools进行热部署

2).使用jrebel进行热部署
注意点:jrebel的路径不能有空格

设置下运行配置即可,第一次启动会卡住,之后运行完好,jrebel比devtools快一点,更好用
SpringBoot02——A Simple SpringBoot Project&Hot Deployment的更多相关文章
- maven加载springboot project
maven加载springboot project 1● 下载项目 2● 构建project mvn install mvn package 3● idea加载 4● run启动 ==== ...
- How to use vscode to build a springboot project
How to use vscode to build a springboot project 首先截图一个springboot官网的一个教程说明截图.可以根据这里的指南去创建一个HelloWorld ...
- Simple Maven Project
为pom.xml添加组织,法律和开发人员信息 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=&qu ...
- Deployment is out of date due to changes in the underlying project contents. Deployment is out of date due to changes in the underlying project contents. You'll need to manually 'Redeploy' the projec
原因1:导入的jar包路径不对,造成第一个错误, 原因2:设置右键工程->属性->myeclipse->web->deployment选use workbenk defaul ...
- SpringBoot进阶教程(六十)intellij idea project下建多个module搭建架构(上)
在 IntelliJ IDEA 中,没有类似于 Eclipse 工作空间(Workspace)的概念,而是提出了Project和Module这两个概念.多module有一个父maven工程,多个子工程 ...
- SpringBoot整合篇
目录 SpringBoot整合篇 SpringBoot简介 SpringBoot运行 SpringBoot目录结构 整合JdbcTemplate @RestController 整合JSP 整合JPA ...
- Docker-compose Setup for Self-hosting Development & Deployment Tools
Last week I wrote about my self-hosted Sentry install in 3 Docker containers. This week I want to br ...
- 【SpringBoot实战】实现WEB的常用功能
前言 通常在 Web 开发中,会涉及静态资源的访问支持.视图解析器的配置.转换器和格式化器的定制.文件上传下载等功能,甚至还需要考虑到与Web服务器关联的 Servlet相关组件的定制.Spring ...
- SpringBoot实践 - SpringBoot+mysql
关于springBoot是个神马东西以及优缺点,请自行搜索了解. LZ看到很多关于SpringBoot的Demo,单看一篇总是没法整合SpringBoot与Mysql.没法子,还是自己操刀来一发为妙. ...
随机推荐
- RF问题收集
console中不打印日志 报错信息: 修改pop方法: try: result = result.decode('UTF-8') except UnicodeDecodeError: pass re ...
- orcal 根据打分时间计算打分情况
create or replace function F_GET_TEST(in_ny in date,in_project_id in number ) return number is sRetu ...
- IDEA项目添加第三方依赖
1.在项目WEB-INF文件夹下面新建一个lib文件夹并将我们需要的第三方jar包拷贝进去: Ctrl+Shift+Alt+S打开项目配置页面: 选择我们存放jar包的文件夹: 选择我们需要引入目标依 ...
- SpringMVC restful风格下载文件,文件后缀被截掉
原文:https://blog.csdn.net/wisdomhealth/article/details/78400421 @RequestMapping("/file/{filename ...
- win10安装mysql-最简单教程
工具下载地址 链接: https://pan.baidu.com/s/1XL2wUDrcd9NpT8NOcXoDTQ 提取码: vu34 下载好之后解压. 在目录D:\Program Files\my ...
- 数据科学中的R和Python: 30个免费数据资源网站
1 政府数据 Data.gov:这是美国政府收集的数据资源.声称有多达40万个数据集,包括了原始数据和地理空间格式数据.使用这些数据集需要注意的是:你要进行必要的清理工作,因为许多数据是字符型的或是有 ...
- jeecg bpm流程节点流程节点配置
流程节点 流程节点 cgFormBuildController.do?ftlForm&tableName=jform_leave&mode=onbutton&ftlVersio ...
- 错误:expected initializer before "***"
今天写了一个程序,编译时报了一个错误:expected initializer before "***"报错的语句只是程序开头的一个变量定义语句,怎么会有这样的错误呢,琢磨了半天也 ...
- hadop-eclipse-plugin导入plugins后没有mapreduce视图
这种现象一般由于安装在eclipse\plugins下的插件没有导入的问题. 解决方法:把 eclipse\configuration\org.eclipse.update 删除掉.出现这种情况的原因 ...
- finreport 截图时间的函数