2021年3月5日星期五

Unable to request a controller method

I am requesting for a controller method through jsp page.I am using button,link and spring tags but nothing is working. I am getting this error while clicking the button.

Mar 06, 2021 8:40:46 AM org.springframework.web.servlet.PageNotFound noHandlerFound  WARNING: No mapping found for HTTP request with URI   [/Reservation/reservation/reservation/getReservationList] in DispatcherServlet with name 'spring'  

My jsp page is as below,

<!DOCTYPE html>   <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>   <html>    <body>    <p>Your reservation is confirmed successfully. Please, re-check the details.</p>     First Name : ${reservation.firstName} <br>     Last Name : ${reservation.lastName}     <input type="button" value="bh" onclick="reservation/getReservationList">   <input type="button"  onclick="location.href='/getReservationList'" value="Register" >   <form:form method="GET" commandName="reservation/getReservationList">   <input type="submit" value="submit">   </form:form>   </body>     </html>  

As above I am using different ways to access 'reservation/getReservationList' but nothing is working.

My controller is,

package com.srinath.controller;  import java.util.List;    import org.springframework.beans.factory.annotation.Autowired;  import org.springframework.stereotype.Controller;     import org.springframework.ui.Model;    import org.springframework.web.bind.annotation.ModelAttribute;    import org.springframework.web.bind.annotation.RequestMapping;        import com.srinath.model.Reservation;  import com.srinath.service.InterceptorService;       @RequestMapping("/reservation")     @Controller     public class ReservationController {    @Autowired   private InterceptorService service;        public InterceptorService getService() {      return service;    }    public void setService(InterceptorService service) {      this.service = service;    }    @RequestMapping("/bookingForm")      public String bookingForm(Model model)       {      //create a reservation object       Reservation res=new Reservation();      //provide reservation object to the model       model.addAttribute("reservation", res);       return "reservation-page";      }     @RequestMapping("/submitForm")     // @ModelAttribute binds form data to the object     public String submitForm(@ModelAttribute("reservation") Reservation res)     {     System.out.println(res.getFirstName()+" "+res.getLastName());   service.Insert(res);   return "confirmation-form";      }    @RequestMapping("/getReservationList")    //@ModelAttribute binds form data to the object    public List<Reservation> getReservationList()    {    List<Reservation> rlist=service.showResults();  return rlist;    }   }    

The methods bookingForm and submitForm are working fine.But unable to call getReservationList method.

https://stackoverflow.com/questions/66502101/unable-to-request-a-controller-method March 06, 2021 at 11:34AM

没有评论:

发表评论