File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Application Frameworks and the fly likes how to  tell  MultiActionController Command Object is Of type com.dss.ems.model.User Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "how to  tell  MultiActionController Command Object is Of type com.dss.ems.model.User" Watch "how to  tell  MultiActionController Command Object is Of type com.dss.ems.model.User" New topic

how to tell MultiActionController Command Object is Of type com.dss.ems.model.User

ganesh pol
Ranch Hand

Joined: Apr 29, 2005
Posts: 151
hi friends
normally in spring's simple form controller we are registering one command object for one controller
like following code

class ="com.dss.ems.controllers.LoginController">
<property name="sessionForm"><value>true</value></property>
<property name="commandName"><value>usermodel</value></property>
<property name="commandClass"><value>com.dss.ems.models.UserModel</value></property>

but in multiaction controller how should we proceed to register one command object for one method

i will give u one example

my Controller code is

public class LoginController extends MultiActionController{
private Map userMap=null;

public LoginController() {
System.out.println(" In LoginController ");

public ModelAndView showLoginPage(HttpServletRequest request,
HttpServletResponse response,
Object obj) throws ServletException {
System.out.println("i am giving login page");
ModelAndView mav=new ModelAndView("login");
mav.addObject("usermodel",new UserModel());
return mav;

// problem part
public ModelAndView authenticateUser(HttpServletRequest request,
HttpServletResponse response,
Object command){
System.out.println(" iam in authentication"+command.getClass());
UserModel loginCommand = (UserModel) command;
// in user map we set the username as key
if( loginCommand.getUserName()!=null &&
loginCommand.getPassword()!=null &&
(this.getUserMap()).get(loginCommand.getUserName() ))
) {
System.out.println("you are valid user");
return new ModelAndView("Expense");
else {
System.out.println("you are NOT valid user");
//throw new UserNotFoundException();
return new ModelAndView("login");

public void setUserMap(Map userMap) {
this.userMap =userMap;

public Map getUserMap() {
return this.userMap;


<%@ taglib prefix="c" uri="" %>
<%@ taglib prefix="spring" uri="/spring" %>

Login to Expense Management System

<table width="742" border="0" cellspacing="0" cellpadding="0">
<td colspan="2" style="color:#FFFFFF;background-color:#666699;height:100px;"><span style="font-size:24pt;">
<td width="742" valign="top">
<table width="742" border="0" cellspacing="0" cellpadding="0">
style="font-size:14pt;color:#FFFFFF;background-color:#9999CC;" align="right">
<td valign="top" style="font-size:10pt;" align="center">
<form method="POST"
<table width="400"
<td align="right" valign="middle">
<td align="left" valign="middle">
<spring:bind path="usermodel.userName">
<input type="text"
name="<cut value="${status.expression}"/>" value="<cut value="${status.value}"/>">
<td align="right" valign="middle">
<td align="left" valign="middle">
<spring:bind path="usermodel.password">

<input type="password"
name="<cut value="${status.expression}"/>" value="<cut value="${status.value}"/>">

<td colspan="2" align="center">
<input type="submit">
<a href=""><B>FORGOT PASSWORD</B></a>.



<bean id="simpleUrlMapping"
class = "org.springframework.web.servlet.handler.SimpleUrl HandlerMapping">
<property name ="mappings">
<prop key ="login.htm">loginController</prop>
<prop key ="auth.htm">loginController</prop>


<!-- ========================= CONTROLLER DEFINITIONS ========================= -->
<bean id="loginController"
class ="com.dss.ems.controllers.LoginController">
<property name="methodNameResolver" ref="LoginControllerMethodNameResolver"/>
<property name="userMap">

<!-- =========================Method name resolver ========================= -->

<bean id="LoginControllerMethodNameResolver"
class="org.springframework.web.servlet.mvc.multiac tion.PropertiesMethodNameResolver">
<property name="mappings">
<prop key="/login.htm">showLoginPage</prop>
<prop key="/auth.htm">authenticateUser</prop> </props>


<bean id="loginFormValidator"
class="com.dss.ems.formvalidators.LoginFormValidat or"/>

<bean id="viewResolver"
class = "org.springframework.web.servlet.view.InternalReso urceViewResolver">
<property name="viewClass">
<value>org.springframework.web.servlet.view.JstlVi ew</value>
<property name ="prefix">
<property name ="suffix">


INFO: Using JSP 2.0 ExpressionEvaluator
iam in authentication class java.lang.Object
14-Dec-2005 14:27:16 org.springframework.web.servlet.FrameworkServlet processRequest
SEVERE: Could not complete request
at com.dss.ems.controllers.LoginController.authentica teUser(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.j
at java.lang.reflect.Method.invoke(
at org.springframework.web.servlet.mvc.multiaction.Mu ltiActionController.invokeNa
at org.springframework.web.servlet.mvc.multiaction.Mu ltiActionController.handleRe
at org.springframework.web.servlet.mvc.AbstractContro ller.handleRequest(AbstractC
at org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle(Simp
at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet

problem is that how should i tell my MultiActionController Command Object is Of type com.dss.ems.models.Usermodel and not java.lang.Object

please help me friends

[ December 12, 2005: Message edited by: ganesh pol ]
[ December 14, 2005: Message edited by: ganesh pol ]
Rajarshi Ghosh

Joined: Aug 31, 2005
Posts: 1
I did it in this way:

I did not set anything in the xml file, but the form fields mataches to the CalVO.
Hope this helps you.
Arun kumar

Joined: Apr 22, 2008
Posts: 10
In the old method definition
void ModelAndView xxxxx(HttpServletRequest req , HttpServletResponse res , Object obj ){}

change the Object class to the Class that you want to convert
void ModelAndView xxxxx(HttpServletRequest req , HttpServletResponse res , User obj ){}

So that while binding the Class of the User command object will be taken and the values from the request parameters will be bound

Regards,<br /> Arun Kumar<br />----------------------------------<br />SCJP 5.0 86%
Reshma Beerantbail

Joined: Jul 09, 2008
Posts: 1
Rajarshi Ghosh and Arunkumar spk,
Could you please elaborate on your answers? Thanks!

I'm new to Spring as well (and first time poster) and have the exact same error. The bind method mentioned above - where did you add it and how did you use it?

Thanks for any info!
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

"Arunkumar spk" and "Reshma RB", please check your private messages for an important administrative matter.

[Asking smart questions] [About Bear] [Books by Bear]
sudheshna Iyer
Ranch Hand

Joined: Aug 20, 2004
Posts: 71

I have the same problem with the bind. How do I bind the command object in controller.

Did anybody solve this problem. If yes, can you please post the code for:
1. accessing command object in method of MultiactionController
2. JSP code ( do I need any additional tags to bing object)?

Joined: Dec 16, 2008
Posts: 1
Hi I also have the same question.
Flow from JSP-->Controller-->Jsp in multiactionController is vague to me.

My MultiActionController:-
public ModelAndView changePassword(HttpServletRequest request, HttpServletResponse response, Users users) {
/*My Code here.
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("users", users);
return modelAndView;


my Jsp:
<form action="changepassword.htm">
<spring:bind path="users.password">
<input type="password" name="password">

I get this exception & nothing is displayed on the browser window:-
javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean name 'users' available as request attribute

Yusuf<br />SCJP1.5 - 93%
I agree. Here's the link:
subject: how to tell MultiActionController Command Object is Of type com.dss.ems.model.User
It's not a secret anymore!