[英]How to convert Spring MVC to android project using PhoneGap?
[英]How to convert springboot project to spring mvc
我正在做一個春季啟動的項目
我想將其轉換為Spring Web MVC
我嘗試將其轉換為動態Web模塊3.0
我添加了用於調度程序Servlet的WebAppInitializer和視圖解析器
但是,當我部署戰爭時,它已成功部署,但出現HTTP 404
錯誤
我還有什么需要做的嗎?
首先,Spring引導程序是Spring MVC和其他Spring模塊的包裝器。 如果您已經在使用Spring Boot,並且想要添加Web模塊(Spring MVC),則只需輸入到POM文件並添加:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
這將創建一個Spring MVC應用程序,現在該視圖解析器如何? 當我使用Spring MVC進行編碼時,我會實現Thymeleaf以便執行視圖,因此Spring將在我的情況下對此進行管理,因此我還添加了:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
此視圖(html)保存在文件夾資源/模板中
和thadaaaaaa,我在控制器中唯一要做的就是將字符串返回給該模板
@GetMapping("/detail/{id}")
private String publicationDetail(@PathVariable Integer id, Model model) {
Optional<CatalogEntity> product = catalogService.getProducById(id);
model.addAttribute("product",product.get());
counter(model);
return "/catalog/detail";
}
但是,如果您不使用Thymeleaf,它也應該返回視圖的字符串,但只需將其保存在我提到的文件夾中
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.