Erhalten Sie den HTTP-Status nach einer Anfrage mit Spring MVC

Ich sende Daten an einen Server und möchte den HTTP-Antwortstatus empfangen, um diesen Status zu überprüfen und die entsprechende Ansicht bereitzustellen

<code>   @RequestMapping(method = RequestMethod.POST)
     public String Login(@ModelAttribute("Attribute") Login login, Model model,HttpServletRequest request) {

          // Prepare acceptable media type
          ArrayList<MediaType> acceptableMediaTypes = new ArrayList<MediaType>();
          acceptableMediaTypes.add(MediaType.APPLICATION_XML);

          // Prepare header
          HttpHeaders headers = new HttpHeaders();
          headers.setAccept(acceptableMediaTypes);

          HttpEntity<Login> entity = new HttpEntity<Login>(login, headers);

          // Send the request as POST
          try {
           ResponseEntity<Login> result = restTemplate.exchange("http://www.../user/login/", 
                   HttpMethod.POST, entity, Login.class);
          } catch (Exception e) {
          }
      //here i want to check the received status
      if(status=="OK"){
         return "login"
      }
      else          
      return "redirect:/home";
     }
</code>

Antworten auf die Frage(2)

Ihre Antwort auf die Frage