Unable to call Controller method after form submission using Spring MVC 3
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi,
I am a newbie to spring mvc. I have a employee form, which after filling 'submit's to an action, which is mapped to a Java Controller. However, the method is not being invoked. Can anyone help with the same?
Please find the attached code snapshots below.
Controller method signature
jsp form
spring configuration xml - view resolver definitions
Can anyone tell me how do I invoke the Java Controller method from the .jsp page ?
I am a newbie to spring mvc. I have a employee form, which after filling 'submit's to an action, which is mapped to a Java Controller. However, the method is not being invoked. Can anyone help with the same?
Please find the attached code snapshots below.
Controller method signature
jsp form
spring configuration xml - view resolver definitions
Can anyone tell me how do I invoke the Java Controller method from the .jsp page ?
Prasad Shindikar
Ranch Hand
Posts: 114
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Can anyone help?
I have a feeling it has probably go to do something with the View resolvers. If I change the action="addEmployee" to action="addEmployee.do", the web server goes and searches for a page /WEB-INF/jsp/addEmployee.jsp!
What I want is for the link addEmployee to be resolved to /addEmployee which I have already annotated in my controller.
I have a feeling it has probably go to do something with the View resolvers. If I change the action="addEmployee" to action="addEmployee.do", the web server goes and searches for a page /WEB-INF/jsp/addEmployee.jsp!
What I want is for the link addEmployee to be resolved to /addEmployee which I have already annotated in my controller.
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
how do you map your dispatcher controller, in web.xml, I assume you used .do as the pattern, so you action have to be sufixed with .do, otherwise spring won't intercept it for you.
Do you know why this cup is useful? Because it is empty.
Prasad Shindikar
Ranch Hand
Posts: 114
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi Hongli Li,
Please read my earlier post.
Yes, I have a dispatcher servlet with .do pattern. However, if I add .do as the extension, it searches for the following resource /WEB-INF/jsp/addEmployee.jsp due to the View Resolver configuration.
Instead, what I want is for the link to be mapped to a Controller which is annotated with
Please read my earlier post.
Yes, I have a dispatcher servlet with .do pattern. However, if I add .do as the extension, it searches for the following resource /WEB-INF/jsp/addEmployee.jsp due to the View Resolver configuration.
Instead, what I want is for the link to be mapped to a Controller which is annotated with
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Can you please show us your web.xml?
Prasad Shindikar
Ranch Hand
Posts: 114
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Here's my web.xml
This is my spring configuration file
PS: The BeanNameViewResolver may or may not be necessary. I was just trying a couple of things and hence have added this entry.
This is my spring configuration file
PS: The BeanNameViewResolver may or may not be necessary. I was just trying a couple of things and hence have added this entry.
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
1. In jsp file add '.do' to the action action="addEmployee.do"
2.In the Spring config file add the mapping for this url
<bean name="/addEmployee.do" class="<give your controller class location with full package structure>"/>
Try this and let me know.
2.In the Spring config file add the mapping for this url
<bean name="/addEmployee.do" class="<give your controller class location with full package structure>"/>
Try this and let me know.
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
You are mapping *.do requests to spring dispatcher servlet.. but in jsp file you are just calling addEmployee, then how are you expecting the spring servlet to handle this request for you.. change addEmployee to addEmployee.do in jsp file as well as @Requestmapping.. it should work..
Prasad Shindikar
Ranch Hand
Posts: 114
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
@Dharmakumar
If I do this, my tomcat crashes during startup with the following error
@Prasad Krishnegowda
I had earlier tried doing that, but the request addEmployee.do was being resolved to /WEB-INF/jsp/addEmployee.jsp which is my default ViewResolver configuration in spring config file.
However, I tried the same again right now and it has worked. I have no idea why it had not worked the first time and why was it going to the ViewResolver earlier.
Anyway, thanks for your help!
2.In the Spring config file add the mapping for this url
<bean name="/addEmployee.do" class="<give your controller class location with full package structure>"/>
If I do this, my tomcat crashes during startup with the following error
@Prasad Krishnegowda
I had earlier tried doing that, but the request addEmployee.do was being resolved to /WEB-INF/jsp/addEmployee.jsp which is my default ViewResolver configuration in spring config file.
However, I tried the same again right now and it has worked. I have no idea why it had not worked the first time and why was it going to the ViewResolver earlier.
Anyway, thanks for your help!
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Were you able to resolve this. I am having the same problem. I am trying call the controller from a jsp. I am not sure how to write this mapping in the Spring Config file.
| Dinner will be steamed monkey heads with a side of tiny ads. The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |










