aspose file tools*
The moose likes Spring and the fly likes How to invoke method using controller class in spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "How to invoke method using controller class in spring" Watch "How to invoke method using controller class in spring" New topic
Author

How to invoke method using controller class in spring

Mohan rvscas
Ranch Hand

Joined: Jul 03, 2010
Posts: 39
Dear Friends,

How to invoke multiple method using controller class in spring.

if you have code or any web references please send me.

Thanks in advance.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Can you explain what you want to do ? What do you mean by "invoke multiple method using controller class" ?


[My Blog]
All roads lead to JavaRanch
Mohan rvscas
Ranch Hand

Joined: Jul 03, 2010
Posts: 39
sir,

i want to call method that is inside the class. see MultiActionControllerEx1.java this java file that extends MultiActionController and it has one method add().

now i have jsp (redirect.jsp). in this jsp i have one anchor tag. it shoult call add method of the class (MultiActionControllerEx1.java) .

i have tried but i didn't get the output .

Error is occured like

HTTP Status 404 - /MultiActionSpring/user.htm/add

type Status report

message /MultiActionSpring/user.htm/add

description The requested resource (/MultiActionSpring/user.htm/add) is not available.
Apache Tomcat/6.0.20


i don't know how where i did the mistake .

This is my code .

redirect.jsp







MultiActionControllerEx1.java








dispatcher-servlet.xml








user.jsp







web.xml





sir this is what i have tried.

please give me the solution.

Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

/MultiActionSpring/user.htm/add ? Your DispatcherServlet is mapped to *.htm. The request associated to that URL will not be processed by the dispatcher. I see at least two problems
1. You defined a method name parameter called "method", but you are not using it
2. You mapped the controller to /user/*.htm but you are linking to user.htm in your JSP

I think you should change "<a href="user.htm/add">Add</a> " to something like "<a href="/yourcontext/user/something.htm?method=add">Add</a>", where "yourcontext" is the name of your application (should be set dynamically). I'm not sure it's wise to map the controller to /user/*.htm.
Mohan rvscas
Ranch Hand

Joined: Jul 03, 2010
Posts: 39

Dear Christophe,

now i made changes in mapping it works fine.

Thanks a lot.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to invoke method using controller class in spring