In Spring 3.0
if i have a jsp page with two different links each calling different method on MultiActionController
<form:form method="POST">
<a href="user.htm?action=add" style="color: blue;">Add</a>
<a href="user.htm?action=delete" style="color: blue;">Delete</a>
</form:form>
on the MultiActionController i get request parameter as null so cannot validate the values
String username=request.getParameter("username");
String password=request.getParameter("password");
i also tried uing a button and changed it to look like a link but in case of button click add method is called twice once with requestparameter as null and second time with correct values, but this twice entry is creating a mess in the code also to make this work i am using form action which will not work in case of two different method calls
<form:form action="user.htm?action=add method="POST">
<input type="submit" value="I have info"/>"> ---> should call delete method
<input type="submit" value="Click to send info"/> ---> should call add method
</form:form>
want to achieve this without javascript
I have also set param reslover in xml file with default method to call
let me explain my problem again forget the above code i was just giving some example
I have a jsp page which has two input text field and two links each should call different method of the controller both the method will validate the input and will get redirect to another page simple!!
The reason i have using MultiActionController....... Unfortunately i have to continue using a controller which extends MultiActionController because the same jsp page also has paging which work absolutely fine
So all i wan to do is simply achieve server and client side validation once either of the link is clicked and redirect accordingly.
Please give me some example to move ahead in this...
i want to achieve this w/o javascript i got this example here but my problem is why the requestParameter is Null
http://www.goospoos.com/2009/11/spri...oller-example/
Here's my code
<bean id="myExampleController" class="com.ui.controller.MyExampleController">
<property name="methodNameResolver">
<ref bean="paramResolver" />
</property>
<property name="validators" ref="myExampleValidator"/>
</bean>
<bean id="paramResolver"
class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
<property name="defaultMethodName" value="loadPage"></property>
<property name="paramName">
<value>action</value>
</property>
</bean>
<bean id="myExampleValidator" class="com.validator.MyExampleValidator" />
Controller
public ModelAndView validateValues(HttpServletRequest request, HttpServletResponse response) throws Exception{
ModelAndView mav=null;
----> this is null ???
String value1=request.getParameter("textvalue1");
String value2=request.getParameter("textvalue2");
mav = new ModelAndView("myexample");
mav=getPageData(request, false);
return mav;
}
JSP page
<form action="myexample.htm" method="post">
input type="text" name="textvalue1" size="20" />
input type="text" name="textvalue2" size="20" />
</form>
<a href="myexample.htm?action=validateValues">click to validate</a>
----------> what's wrong with this if the above mentioned site can call a method and works fine ,why i cannot get request parameters