We help IT Professionals succeed at work.

spring UI with controller

royjayd
royjayd asked
on
hi guys
I have a basic question in spring framework.
I have 4 buttons on a jsp page: add, save, delete, update. Each of those 4 buttons when clicked should invoke methods in controller. So i guess i need only one controller with 4 methods right?
add () , save () , delete ()  and  update() , will that be correct?

how do i map the buttons to the methods? i.e when user click on the add button, add() should be invoked in controller.
(In struts we used dispatch action class, not sure how we do in spring)

Any sample code in implimenting this scenario would greatly help.

thanks

Comment
Watch Question

Java Developer
Top Expert 2010
Commented:

Author

Commented:
thanks for the link, its pretty handy. have  a question

in this line :   3> Change in Application-servlet.xml

Is Application-servlet.xml file an in-built file provided by spring in addition to web.xml and spring-config.xml?

thanks
Mick BarryJava Developer
Top Expert 2010

Commented:
no, you write that. It specifies your mappings.

Author

Commented:
ok, so what xml files do we need for spring which we need to modify:

web.xml
spring-config.xml
application-servlet.xml

anythig else?
thanks

thanks.
Mick BarryJava Developer
Top Expert 2010

Commented:
you can put your mappings in whatever files you want. you just need to tell spring which files to load.
the example above just seperates the ui mappings from the application bean mappings.

Author

Commented:
ok, so in the above example since user created a Application-servlet.xml file and defined the ParameterMethodNameResolver class in it which does the job of mapping 'parametres' with method names, is Application-servlet.xml  registered anywhere else? How does spring know user has created
Application-servlet.xml ?

Can i omit the Application-servlet.xml  file and put its content in my spring-config file?

thanks
Mick BarryJava Developer
Top Expert 2010

Commented:
what the file is named is irrelevant

> Can i omit the Application-servlet.xml  file and put its content in my spring-config file?

yes

Author

Commented:
ok. got it.
thanks.