【问题标题】:AWS lambda/api gateway does not redirectAWS lambda/api 网关不重定向
【发布时间】:2020-02-18 16:57:43
【问题描述】:
我有一个非常简单的 spring 路线,我试图在 aws lambda 上运行。该路由只返回文本/字符串“redirect:/upload”而不是重定向。我在 /resources/templates 文件夹中有 html 文件。
@RequestMapping(path = "/test", method = RequestMethod.POST)
public String UploadPage2() {
return "redirect:/upload";
}
【问题讨论】:
标签:
java
spring
amazon-web-services
amazon-s3
【解决方案1】:
我认为问题出在方法的返回类型:String。
你可以这样做:
public RedirectView UploadPage2() {
return new RedirectView("/upload");
}
第二个问题
要使用GET 请求返回路径/test 上的视图,您需要另一个具有相同path 但不同method 的方法
@RequestMapping(path = "/test", method = RequestMethod.GET)
public ModelAndView testGet(){
return new ModelAndView("uploadview");
}