SpringBoot使用JSP

2020-03-01  本文已影响0人  我问你瓜保熟吗
491787.jpg
        <!-- 只能打成war包,不支持打成jar包 -->
        <packaging>war</packaging>



        <!--引入Spring Boot内嵌的Tomcat对JSP的解析包-->
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>

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

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

        <!--servlet依赖的jar包-->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>
spring:
  mvc:
    view:
      prefix: /WEB-INF/pages/
      suffix: .jsp

# 或者
spring.view.prefix=/WEB-INF/views/
spring.view.suffix=.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title></head>
<body>
    ${welcome}
</body>
        <resources>
            <resource>
                <directory>src/main/webapp</directory>
                <targetPath>META-INF/resources</targetPath>  <!--编译后的路径:/target/META-INF/resources-->
                <includes>
                    <include>**/*.*</include>
                </includes>
            </resource>
        </resources>
上一篇下一篇

猜你喜欢

热点阅读