2

i get this exception when starting the server : HTTP Status 405 - Request method 'GET' not supported

my controller is :

@Controller
public class HomeController {

    private static final Logger logger = LoggerFactory.getLogger(HomeController.class);

    @RequestMapping(value = "/", method = RequestMethod.POST)
    public String home(Locale locale, Model model) {
        logger.info("Welcome home! The client locale is {}.", locale);

        return "login";
    }

}

i really don't know what is the problem, since i am a very new to spring, could not even figure out what the problem is.

could somebody guide me to fix this

Java Questions
  • 7,813
  • 41
  • 118
  • 176

3 Answers3

3

RequestMapping is wrong.

@RequestMapping(value = "/", method = RequestMethod.POST)

It will take only POST request and return 405 StatusCode any request not POST.

So, It should be

@RequestMapping(value = "/", method = RequestMethod.GET)

dgregory
  • 1,397
  • 1
  • 12
  • 26
2

Try this

change

@RequestMapping(value = "/", method = RequestMethod.POST)

to

@RequestMapping(value = "/login", method = RequestMethod.GET)

(In your previous post I noticed that you have login-page=login)

Kris
  • 1,882
  • 1
  • 20
  • 23
1

Change

@RequestMapping(value = "/", method = RequestMethod.POST)

to

@RequestMapping(value = "/login", method = RequestMethod.GET)
ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213