簡體   English   中英

Spring Controller的URL請求映射僅對帶有字符串的空白頁無效

[英]Spring Controller's URL request mapping not working only a blank page with a string

大家好,目前正在從事這個項目! https://github.com/fedexu/FilmRental

我映射了實體,並創建了一個HelloWorldController

@RestController
public class helloWord {

@RequestMapping(value="/login", method=RequestMethod.GET)
public String handleRequest() throws Exception {
    return "login";
}

在WebServiceConfig.java中添加

@Bean
public InternalResourceViewResolver resolver() {
   InternalResourceViewResolver resolver = new InternalResourceViewResolver();
   resolver.setPrefix("webapp/views/");
   resolver.setSuffix(".html");
   return resolver;
}

我通過http:// localhost:8080 / FilmRental / login的方式創建視圖login.html,我有一個空白頁面,其中包含String登錄名(如返回String),而不是視圖

@RestController更改為@Controller 前者用於返回對象而不是視圖

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM