Ciao Tutti,
I have one problem in the Spring MVC . As i am new to it.
I am using the annotation in the controller
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).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<String> populateUserList() {
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";
}
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


Reply With Quote