zoukankan      html  css  js  c++  java
  • spring boot学习02【如何在spring boot项目中访问jsp】

    1.配置application.properties文件

    打开application.properties追加

    spring.mvc.view.prefix=/WEB-ROOT/

    spring.mvc.view.suffix=.jsp


    2. 在pom.xml中添加访问jsp页面的jar包

      <!-- 访问jsp页面所需要的以下依赖包 -->
          <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>

    3.创建IndexControl类

    import org.springframework.stereotype.Controller;

    import org.springframework.web.bind.annotation.RequestMapping;

    import org.springframework.web.bind.annotation.RequestMethod;

     

    @Controller

    public class IndexControl {

      @RequestMapping(value="/index",method = RequestMethod.GET

       public String index() {

          return "index"; 

         }

     

    }

    在项目的contrl包下创建IndexControl类

    4.创建jsp文件

    新建index.jsp文件,放到srcmainwebappWEB-ROOT 目录下,没有目录新建即可

    5.访问地址如下:

    http://127.0.0.1:8080 或者http://localhost:8080/index/都可以访问到我们的首页文件index.jsp

  • 相关阅读:
    Gson字符串编码,字符串转换成图片保存,二进制转换成图片保存
    时间工具类DateUtil
    RSA 签名、验证、加密、解密帮助类
    富友数据加密解密
    Base64(2)
    MD5(2)
    实体对象操作工具
    HttpClient工具类
    MD5
    身份证算法实现
  • 原文地址:https://www.cnblogs.com/soulsjie/p/8469691.html
Copyright © 2011-2022 走看看