user8787628
user8787628

Reputation:

AWS lambda/api gateway does not redirect

I have a very simple spring route that im attempting to run on aws lambda. The route simply returns the text/string "redirect:/upload" instead of redirecting. I have the html file in the /resources/templates folder.

@RequestMapping(path = "/test", method = RequestMethod.POST)
    public String UploadPage2() {
        return "redirect:/upload";
    }

Upvotes: 0

Views: 288

Answers (1)

KunLun
KunLun

Reputation: 3227

I think the problem is from the return type of method: String.

You can do:

public RedirectView UploadPage2() {
    return new RedirectView("/upload");
}

Second question

To return an view on path /test with GET request, you need another method with same path but different method

@RequestMapping(path = "/test", method = RequestMethod.GET) 
public ModelAndView testGet(){
    return new ModelAndView("uploadview");
}

Upvotes: 1

Related Questions