springboot2.1.3jsp模板配置

字体大小: 中小 标准 ->行高大小: 标准


@SpringBootApplication
@Controller
@RequestMapping(value = "/test")
public class WebApplication {//extends SpringBootServletInitializer

    @RequestMapping(value = "/test")
    public ModelAndView test(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("hi","aaaaaaaaaaaaaaa");
        modelAndView.setViewName("h");
        System.out.println("run test  `````````````````````````````````````");
        return modelAndView;
    }
 public static void main(String[] args) {
  SpringApplication.run(WebApplication.class, args);
 }

}

 

server.port=6001
#/templates/  /WEB-INF/
spring.mvc.view.prefix=/WEB-INF/jsp/ 
spring.mvc.view.suffix=.jsp
spring.mvc.log-resolved-exception=false
spring.mvc.static-path-pattern=/**
#覆盖默认配置,所以需要将默认的也加上否则static、public等这些路径将不能被当作静态资源路径
#在最末尾的file:${web.upload-path}中的file:表示是一个具体的硬盘路径,其他的使用classpath指的是系统环境变量
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/

 

<dependencies>
  <dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-web</artifactId>
  </dependency>

  <dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-test</artifactId>
   <scope>test</scope>
  </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <!--<scope>provided</scope>-->
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
        <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>
 </dependencies>

 <build>
  <plugins>
   <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
   </plugin>
  </plugins>
        <resources>
            <!-- 打包时将jsp文件拷贝到META-INF目录下 -->
            <!--<resource>-->
                <!--&lt;!&ndash; 指定resources插件处理哪个目录下的资源文件 &ndash;&gt;-->
                <!--<directory>web</d0irectory>-->
                <!--&lt;!&ndash;注意此次必须要放在此目录下才能被访问到 &ndash;&gt;-->
                <!--<targetPath>META-INF/resources</targetPath>-->
                <!--<includes>-->
                    <!--<include>**/**</include>-->
                <!--</includes>-->
            <!--</resource>-->
            <resource>
                <!-- 指定resources插件处理哪个目录下的资源文件 最重要是这里了,jsp放其它目录都没用,只能这样放,这样打包操作 spring-boot版本为2.1.3-->
                <directory>src/main/webapp</directory>
                <!--注意此次必须要放在此目录下才能被访问到 -->
                <targetPath>META-INF/resources</targetPath>
                <includes>
                <include>**/**</include>
                </includes>
            </resource>
            <!--<resource>-->
                <!--<directory>src/main/resources/lib</directory>-->
                <!--<targetPath>BOOT-INF/lib/</targetPath>-->
                <!--<includes>-->
                    <!--<include>**/*.jar</include>-->
                <!--</includes>-->
            <!--</resource>-->
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/**</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
 </build>
 
 
src/main/webapp/WEB-INF/jsp/
在这里建立jsp模板即可

此文章由 http://www.ositren.com 收集整理 ,地址为: http://www.ositren.com/htmls/70840.html