【问题标题】:Where I must put my jsp files in SpringBoot? [duplicate]我必须将我的 jsp 文件放在 SpringBoot 的什么地方? [复制]
【发布时间】:2017-12-10 07:31:39
【问题描述】:

我给你写信是因为我不知道我必须将我的 JSP 文件放在 SpringBoot 应用程序中的什么位置..

A screen of my application's files

提前感谢您的回复, 诺曼。

PS:对不起,我不能在帖子开头打招呼,它总是被删除..

【问题讨论】:

  • 谢谢你,我要读这篇文章:)

标签: spring file spring-boot


【解决方案1】:

您应该将文件放到src/main/resources/static(或src/main/resources/publicsrc/main/resources/resources)。所有这些都是由 Spring Boot 自动配置注册的。

您还应该将以下属性添加到application.properties

spring.mvc.view.suffix=.jsp

【讨论】:

  • 好的,非常感谢!!但是我没有静态文件。我必须创建一个?
  • 当然,你应该创建它
  • 完美!感谢您的帮助:)
【解决方案2】:

在春季添加jsp文件的关键 为此,以下步骤很重要: - 在 src/main 中创建名为 webapp 的文件夹 - 在其中创建名为 WEB-INF 的文件夹 - 将此行添加到您的 pom 文件中

    <!-- Spring MVC framework -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <!-- JSTL -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>${jstl.version}</version>
    </dependency>

    <!-- for compile only, your container should have this -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>${servletapi.version}</version>
        <scope>provided</scope>
    </dependency>

</dependencies>
  • 创建 mvc-dispatcher-servlet.xml
  • 创建 web.xml 文件

您可以访问网址以获取有关步骤press here的更多详细信息

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-26
    • 2015-05-16
    • 1970-01-01
    • 2020-03-06
    • 2020-02-26
    • 1970-01-01
    • 2022-01-23
    • 2017-08-29
    相关资源
    最近更新 更多