java WEB-INF 文件夹未在 Spring Boot 应用程序中创建?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48277952/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 10:01:13  来源:igfitidea点击:

WEB-INF folder is not creating in Spring Boot application?

javaspringjspspring-mvcspring-boot

提问by Rajanikanta Pradhan

I am creating a Spring Boot application, using Spring Initializr, But the folder structure is bit different, there is no WEB-INFfolder, so where I will put the JSP files, shall I create the WEB-INFfolder manually?

我正在创建一个 Spring Boot 应用程序,使用 Spring Initializr,但是文件夹结构有点不同,没有WEB-INF文件夹,那么我将把 JSP 文件放在哪里,我应该WEB-INF手动创建文件夹吗?

采纳答案by sapan prajapati

We need to crate WEB-INF folder manually in spring boot application. Follow below steps to create WEB-INF folder

我们需要在 spring boot 应用程序中手动创建 WEB-INF 文件夹。按照以下步骤创建 WEB-INF 文件夹

  1. Select main folder as highlighted below.

    enter image description here

  2. Right click and create a folder with name webapp.
  3. Now right click on webappfolder and create WEB-INFfolder.
  4. Now similarly create a viewfolder (or any other name you like) inside WEB-INF folder to keep all the JSPs.
  5. Below should be the folder structure after doing above steps.

    enter image description here

  1. 选择如下突出显示的主文件夹。

    在此处输入图片说明

  2. 右键单击并创建一个名为webapp的文件夹。
  3. 现在右键单击webapp文件夹并创建WEB-INF文件夹。
  4. 现在同样在 WEB-INF 文件夹中创建一个视图文件夹(或您喜欢的任何其他名称)以保存所有 JSP。
  5. 下面应该是完成上述步骤后的文件夹结构。

    在此处输入图片说明

回答by craigwor

Usually the web files will go into the resources folder with spring boot. https://spring.io/guides/gs/serving-web-content/

通常 web 文件会通过 spring boot 进入资源文件夹。 https://spring.io/guides/gs/serving-web-content/

回答by arc

Dumping the jsp files in src/main/webappfolder worked for me, both with or without WEB-INF. I followed the exact project structure mentioned in

转储文件src/main/webapp夹中的 jsp 文件对我有用,无论有没有 WEB-INF。我遵循了中提到的确切项目结构

  1. mkyong.com
  2. springboottutorial
  1. mkyong.com
  2. springboot教程

回答by user3997694

I had the same problem. To solve this, You need to change in your pom.xmlfrom jarto war, and do the following...

我有同样的问题。要解决此问题,您需要将pom.xmljar更改为war,然后执行以下操作...

cd "my_project"
mvn clean package
java -jar my_project.war

And everything workout.

和一切锻炼。

回答by Bhumit Thakkar

Inside:src/main/resources/application.properties

内部:src/main/resources/application.properties

Add this line:spring.mvc.view.prefix = /WEB-INF/view/

添加这一行:spring.mvc.view.prefix = /WEB-INF/view/

Knowledge Sourcewatch 5 minutes: VideoStart at: 55:33

知识源观看 5 分钟:视频开始时间:55:33