美文网首页Java
springboot(一):集成jsp

springboot(一):集成jsp

作者: 修远路 | 来源:发表于2018-08-29 15:10 被阅读0次

1.注解

@RestController <=> @Controller + @ResponseBody

@GetMapping("users") <=> @RequestMapping(value = "users", method = RequestMethod.GET)

@PostMapping @PutMapping @DeleteMapping同理

2.JSP集成

pom添加

  • dependencies节点
<!-- springboot内嵌的tomcat对jsp的解析包 -->
<dependency>
   <groupId>org.apache.tomcat.embed</groupId>
   <artifactId>tomcat-embed-jasper</artifactId>
</dependency>

<!-- servlet依赖jar包 -->
<dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>javax.servlet-api</artifactId>
</dependency>

<!-- jsp依赖jar包 -->
<dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>jsp-api</artifactId>
</dependency>

<!-- jstl依赖jar包 -->
<dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>jstl</artifactId>
</dependency>

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-test</artifactId>
   <scope>test</scope>
</dependency>
  • build节点
<!-- compile -->
<resources>
   <resource>
      <directory>src/main/java</directory>
      <includes>
         <include>**/*.xml</include>
      </includes>
   </resource>
   <resource>
      <directory>src/main/resources</directory>
      <includes>
         <include>**/*.*</include>
      </includes>
   </resource>
   <resource>
      <directory>src/main/webapp</directory>
      <targetPath>META-INF/resources</targetPath>
      <includes>
         <include>**/*.*</include>
      </includes>
   </resource>
</resources>

application.yml添加

spring:
  # 编码
  http:
    encoding:
      charset: utf-8
      enabled: true
      force: true
  # jsp
  mvc:
    view:
      # 默认src/main/webapp下面
      prefix: /
      suffix: .jsp

[附]git源码地址
https://github.com/SaltzmanAlaric/springboot-jsp

相关文章

  • SpringBoot集成JSP

    SpringBoot我就不介绍了,这里主要将SpringBoot集成JSP,首先我们要知道SpringBoot默认...

  • springboot(一):集成jsp

    1.注解 @RestController <=> @Controller + @ResponseBody@GetM...

  • SpringBoot集成jsp

    1、创建Maven项目 2、引入pom.xml依赖 2、创建properties配置文件 3、创建jsp文件夹 4...

  • Springboot集成jsp

    1.引入依赖,在pom.xml文件中加入 2.配置application.properties文件,指定jsp文件...

  • springboot集成jsp

    一、创建项目 第一步 创建spring Initializr 第二步 packing 选择war 第三步 core...

  • SpringBoot集成Jsp

    第一步:创建项目 第二步:添加依赖 第三步:创建jsp页面存放文件夹 第四步:解决鼠标右键没有创建jsp文件选项问题

  • SpringBoot与JSP集成

    SpringBoot内嵌Web容器的,推荐打成jar包不是war包,如果使用JSP打成war包使用外部容器,这就相...

  • 1、Springboot 集成 jsp

    pom.xml文件 org.apache.tomcat.embed

  • SpringBoot 集成

    SpringBoot 集成 redis SpringBoot集成mongodb SpringBoot集成Beetl...

  • 如何让springboot jetty容器支持jsp Not v

    问题描述 springboot 如何让jetty容器支持jsp springboot 访问jsp页面tomcat正...

网友评论

    本文标题:springboot(一):集成jsp

    本文链接:https://www.haomeiwen.com/subject/maxkwftx.html