[英]spring boot tomcat jsp is downloaded not rendered
我正在將我的 spring 應用程序引導到 spring boot,並且我遇到的問題是嵌入式 tomcat 沒有呈現 jsp 文件,而是將下載文件。
我已經用谷歌搜索並嘗試了到目前為止我發現的所有東西,但我仍然做錯了什么。
我的 pom.xml 文件中有以下依賴項
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<!-- Need this to compile JSP -->
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>4.6.1</version>
</dependency>
從 application.properties 剪輯
server.port=8080
spring.mvc.view.prefix=/
spring.mvc.view.suffix=.jsp
從控制器剪輯
@GetMapping(value= "/")
public String showPage(Model theModel) {
theModel.addAttribute("scrumbled", new Scrumbled());
return "main";
}
下載jsp文件而不是在瀏覽器中顯示和呈現我做錯了什么?
提前致謝
問題出在碧玉版本上。 無論tomcat版本如何,它都適用於以下版本。
<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-jasper -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jasper</artifactId>
<version>9.0.24</version>`enter code here`
</dependency>
我的 tomcat 版本是 9.0.63。
我已經解決了這個問題。
問題是損壞的 jar 依賴項。 我不得不 maven clean,maven install 整個項目才能看到錯誤。 從文件系統中刪除 jar 后,maven 再次下載了依賴項,現在它可以工作了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.