Results 1 to 10 of 14

Thread: RequestMaping calling two times for one submit

Threaded View

  1. #1

    Unhappy RequestMaping calling two times for one submit

    Ciao Tutti,

    I have one problem in the Spring MVC . As i am new to it.

    I am using the annotation in the controller

    PHP Code:
    @Controller
    public class WelcomeAnnotatedController {

        
    Log log LogFactory.getLog(this.getClass());

        @
    Autowired
        
    private SecondBean secondBean;
        
    //it will call the method, when the submitting the form
        
    @RequestMapping(value="/actionName.htm",method RequestMethod.POST)
        public 
    ModelAndView onSubmit() {
            
    System.out.println("<<<<<<<<<<<<<onSubmit POST WelcomeAnnotatedController>>>>>>>>>>>>>>>>>>>>>>>");
            
    String message secondBean.getFirstBean().foo();
            
    System.out.println("<<<<<<<<<<<<<Message>>>>>>>>>>>>>>>>>>>>>>>" message );
            
    ModelAndView mav = new ModelAndView("myview").addObject("message",message);
            return 
    mav;
        }

        @
    ModelAttribute("userList")
        public List<
    StringpopulateUserList() {
            
    ArrayList<String> list = new ArrayList<String>();
            list.
    add("Rahul");
            list.
    add("Joy");
            list.
    add("Anand");
            return list;
        }

        @
    RequestMapping(method RequestMethod.GET)
        public 
    String showForm(ModelMap map) {
            
    map.addAttribute("message""Hello,This is My First Jsp");
            
    System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<showUserForm GET WelcomeAnnotatedController>>>>>>>>>>>>>>>>>>>>>>>>>>>");
            
    User user = new User();
            
    map.addAttribute("user"user);
            return 
    "myview";
        }

        @
    RequestMapping(value="/backUser.htm",method RequestMethod.POST)
        public 
    String backToWelcome() {
            
    System.out.println("going back to welocme page");
            return 
    "welcome";
        } 
    Whenever i am calling the RequestMapping method, its calling two times, here when i am trying to addUser, its tried to insert two times(Sometime).

    I am not able to figure out what is the problem. Whenever i am calling the same RequestMapping continously 3-4 times,suppose in this case @RequestMapping(value="/backUser.htm",method = RequestMethod.POST), then it will call two times.
    output of the RequestMapping as
    <<<<<<<<<<<<<<<<<<<<<<<<<showUserForm GET WelcomeAnnotatedController>>>>>>>>>>>>>>>>>>>>>>>> >>>
    going back to welocme page
    <<<<<<<<<<<<<<<<<<<<<<<<<showUserForm GET WelcomeAnnotatedController>>>>>>>>>>>>>>>>>>>>>>>> >>>
    going back to welocme page
    <<<<<<<<<<<<<<<<<<<<<<<<<showUserForm GET WelcomeAnnotatedController>>>>>>>>>>>>>>>>>>>>>>>> >>>
    going back to welocme page
    <<<<<<<<<<<<<<<<<<<<<<<<<showUserForm GET WelcomeAnnotatedController>>>>>>>>>>>>>>>>>>>>>>>> >>>
    going back to welocme page
    <<<<<<<<<<<<<<<<<<<<<<<<<showUserForm GET WelcomeAnnotatedController>>>>>>>>>>>>>>>>>>>>>>>> >>>
    going back to welocme page
    <<<<<<<<<<<<<<<<<<<<<<<<<showUserForm GET WelcomeAnnotatedController>>>>>>>>>>>>>>>>>>>>>>>> >>>
    going back to welocme page
    going back to welocme page


    Please help me , because , i am going to use SPRING MVC first time.

    Thanks
    Rahul
    Last edited by sunflower_rahul; Jan 23rd, 2010 at 06:45 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •