[英]Cannot acess a JSP page using Spring Boot
I'd would like to add mapping in Spring Boot
(1.5.4) for a jsp
page. 我想在Spring Boot
(1.5.4)中为jsp
页面添加映射。 First of all, I started by creating in project in IntelliJ
. 首先,我首先在IntelliJ
创建项目。 Then I added a few packages in pom.xml
. 然后我在pom.xml
添加了一些软件包。 Now I have in this file the following dependencies: 现在,此文件中具有以下依赖项:
Next, I created a class to make a mapping for /login
. 接下来,我创建了一个类来为/login
进行映射。
@Controller
public class LoginController
{
@RequestMapping("/login")
public String login()
{
return "login";
}
}
I created login.jsp
file in the location of src/main/webapp/web-inf/jsp
. 我在src/main/webapp/web-inf/jsp
的位置创建了login.jsp
文件。
Lastly, I added the following in application.properties
: 最后,我在application.properties
添加了以下内容:
spring.mvc.view.prefix = /WEB-INF/jsp/
spring.mvc.view.suffix = .jsp
Unfortunelty, when I try access localhost/login
I get the Whitelabel Error Page
page. 不幸的是,当我尝试访问localhost/login
我得到了Whitelabel Error Page
页面。 What have I missed with configuration? 我错过了哪些配置?
I have faced the same problem today and have found your question while googling the solution. 我今天也遇到了同样的问题,并且在搜索解决方案时发现了您的问题。
It is a common IntelliJ problem, so, I'll tell you, what I have done to make app work (hope it will help). 这是一个常见的IntelliJ问题,所以,我将告诉您,我为使应用程序正常工作所做的事情(希望它会有所帮助)。
First of all, try to go to http://localhost:8080/login (you mentioned localhost without port number). 首先,尝试转到http:// localhost:8080 / login (您提到的localhost没有端口号)。 If this doesn't help, try the following steps: 如果这样做没有帮助,请尝试以下步骤:
Open IntelliJ Terminal, type "mvn clean install" (without quotes) -> ENTER -> wait untill the process will finish -> you shoul see a message something like: 打开IntelliJ Terminal,输入“ mvn clean install”(不带引号)-> ENTER->等待该过程完成->您应该看到类似以下的消息:
[INFO] BUILD SUCCESS [INFO] -------------------------------------------------------------- [INFO] Total time: 9.339 s [INFO] Finished at: 2018-03-03T00:46:58+02:00 [INFO] Final Memory: 36M/273M [INFO] [INFO]成功建立[INFO] ------------------------------------------ -------------------- [INFO]总时间:9.339 s [INFO]完成于:2018-03-03T00:46:58 + 02:00 [INFO]最终内存:36M / 273M [INFO]
Go to browser -> http://localhost:8080/login -> your login.jsp page should appear (if no luck try CTRL+F5 on Windows/Linux to refresh webpage cash). 转到浏览器-> http:// localhost:8080 / login->您的login.jsp页面应该出现(如果没有运气,请尝试在Windows / Linux上按CTRL + F5刷新网页现金)。
Hope this gonna help you, as it works for me. 希望这会对您有所帮助,因为它对我有用。
Have fun! 玩得开心! =) =)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.