1

After research on subjects concerning differences between spring boot and previous spring mvc frameworks. I am confused and need some help! How to do redirect to an html page since normally trying to redirect without the page target having a controller method returns HTTP 404.

if I have this controller method below that handles registration confirm:

@RequestMapping(value = "/registrationConfirm", method = RequestMethod.GET)
public String confirmRegistration(final HttpServletRequest request, Model 
model, @RequestParam("token") final String token){
    Locale locale = request.getLocale();
    final String result = userService.validateConfirmationToken(token);
    if (result.equals("valid")) {
        final User user = userService.getUser(token);
        authWithoutPassword(user);
        model.addAttribute("message",          
        messages.getMessage("message.accountVerified", null, locale));
        return "redirect:/home.html?lang=" + locale.getLanguage();
    }

    model.addAttribute("message", messages.getMessage("auth.message." + 
    result, null, locale));
    model.addAttribute("expired", "expired".equals(result));
    model.addAttribute("token", token);  
    return "redirect:/wrong.html?lang=" + locale.getLanguage();
    }

I am getting http 404 error not found. Is it a must to have a Controller method specific for wrong.html page? if it is not required, how to run it that way.

msf6012
  • 119
  • 2
  • 13

1 Answers1

0

After your response is redirected to '/wrong.html', spring need to know how to handle '/wrong.html'. Maybe, You made no handler for '/wrong.html', so spring doesn't know how to handle it and responses 404.

This answer might help you : How to serve .html files with Spring

Min Hyoung Hong
  • 1,102
  • 9
  • 13