Thursday 15 September 2011

java - Prefix "redirect:" not able to resolve the view -


I was following the application example in the book - Section 8-10 and I am stuck in an issue. I try to keep it low

I have the following fields in the reservation bean:

  string court name, date date, int   

player bean has just two fields - names , and ages < / Code>.

Sport type a enum :

  public anonym sport type {tennis ("tennis"), soccer ( " Football"); Now, I have a view -  reservationForm.jsp , with the same controller -  the reserve parameter controller  / Em>.  

Administrators have the following annotations:

  @Controller @RequestMapping ("/ reservation form") @ session attraction ("reservation")   
  @RequestMapping (method = RequestMethod.GET) public string setup form (@RequestParam (required = false, value = "username ") String Username, @Racepharmum (essential = true, value =" age ") int age, model model) {System.out.println (" forming set up "); Reservation reservation = new reservation (); Reservation.setPlayer (new player (user name, age)); Model.addAttribute ("reservation", reservation); Return "reservation"; } @RequestMapping (method = RequestMethod.POST) public string submitForm (model model, @model att ("reservation") reservation reservation, binding results, session status status) {reservationValidator.validate (reservation, results); If (result.hasErrors ()) {model.addAttribute ("reservation", reservation); Return "reservation"; } And {reservationService.make (reservation); Status.setComplete (); // The return of the session ends "Redirection: Success"; }} @RequestMapping ("Success") Public String Reservation Success () {System.out.println ("Called"); Return "reservation enabled"; }   

Now, when I deploy the application, I use the url:

  http: // localhost: 8080 / springmvc / reservationForm = Age = 21   

Form reservationForm.jsp has been displayed. And then press the submit button in that form to me, the submitForm () method will be called.

The problem is that if verification is successful, then other blocks:

  return "redirect: successful reservation"  < / Pre> 

is not working. This is showing an HTTP status -404

I have the url displayed in the browser after submitting the form:

  http: // Localhost: 8080 / springmvc / successful reservation? SportTypes = tennis and sporttypes = SOCCER   

I do not know how those 2 request attributes came in the query string.

When I have tested whether the method handler- reservationSuccess () matches the successful reservation , I saw that it should not be called Used to be. Because of that, the scene is not being resolved.

In addition, in Eclipse Console, it is showing a warning:

  Warning: No mapping was found for HTTP request with URI [/ SpringMVC / Successful Reservation ] With the name 'Court' in the Dispatcher Circle   

I do not understand what the problem might be I have added - in the configuration file & lt; Reference: component-scan & gt; .

This is a configured view resolver:

  & lt; Bean square = "org.springframework.web.servlet.view.InternalResourceViewResolver" & gt; & Lt; Property Name = "Prefix" Value = "/ Web-NF / JSP /" /> & Lt; Property name = "suffix" value = ".jsp" /> & Lt; / Bean & gt;   

Also, it seems that the examples of that book are not complete. They have not defined the reservation enabled () method for the reserved URL. That I have added on my own.

Can anyone help me here, what is happening?

The more information I have tried to compact as I can here, if you want some more information, then ask. I would add.

It looks like you should be redirected to / reservationForm / successfulReservation .

Since the law is within the controller, and the administrator also has request-mapping, this method is not independent of the request-mapping controller.

No comments:

Post a Comment