Results 1 to 1 of 1
  1. #1
    Join Date
    Nov 2013
    Location
    coimbatore
    Posts
    7
    Rep Power
    0

    Default How to pass a form one controller to another controller

    Hello to all,

    I am trying to pass a from to one controller to another controller. But I am getting below mentioned error.

    "Could not resolve view with name 'redirect:rolewindow' in servlet with name 'taskTraker' "

    And I have added my code also. Please some one let me know where I am wrong.

    Login.jsp :

    <body>
    <form:form method="post" action="org.sasi.tasktracker.login" commandName="loginForm">

    <table border="1" bgcolor="" align="center">
    <tr>
    <td><spring:message code="label.usercode"/></td>
    <td><form:input path="usernmae"/> <form:errors path="usernmae"/></td>
    </tr>

    <tr>
    <td><spring:message code="label.userpassword"/></td>
    <td><form:input path="userpassword"/> <form:errors path="userpassword"/></td>
    </tr>

    <tr>
    <td><input type="submit" value="<spring:message code="btn.label.cancel"/>" name="cancelbtn"> </td>
    <td><input type="submit" value="<spring:message code="btn.label.login"/>" name="login"> </td>
    </tr>

    </table>

    </form:form>
    </body>

    ---------------------------------------------------------------------------------------------------------------Web.xml:

    <servlet>
    <servlet-name>taskTraker</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>taskTraker</servlet-name>
    <url-pattern>/</url-pattern>
    </servlet-mapping>

    ---------------------------------------------------------------------------------------------------------------TaskTracker-servlet.xml:
    <context:component-scan base-package="org.sasi.tasktracker"/>
    <context:annotation-config />
    <mvc:annotation-driven />

    <bean id="messageSource" class="org.springframework.context.support.Reloada bleResourceBundleMessageSource">
    <property name="basename" value="classpath:resources/messages"/>
    <property name="fallbackToSystemLocale" value="false"/>
    <property name="defaultEncoding" value="UTF-8"></property>
    </bean>

    <bean class="org.springframework.web.servlet.view.XmlVie wResolver">
    <property name="location" value="/WEB-INF/view-servlet.xml"/>
    <property name="order" value="0"/>
    </bean>

    ---------------------------------------------------------------------------------------------------------------LoginController

    @RequestMapping(value="/org.sasi.tasktracker.login",params="login", method=RequestMethod.POST)
    public String onSubmit(@RequestParam(required=false, value ="login") String saveFlag ,HttpServletRequest req,HttpServletResponse res,@ModelAttribute("loginForm") LoginForm loginForm,BindingResult bindingResult,
    SessionStatus session,Model model, RedirectAttributes redirectAttributes ) throws Exception{

    validation.validateLoginDetails(loginForm, bindingResult);

    if(bindingResult.hasErrors()){
    CommonDeclartion.returnValue="org.sasi.tasktracker .loingmodule";
    }
    else{
    List list=loginServiceDao.getUserList(loginForm.getUser nmae(), loginForm.getUserpassword());
    if(list.size()==0){
    CommonDeclartion.returnValue="org.sasi.tasktracker .loingmodule";
    }
    else{
    redirectAttributes.addFlashAttribute("loginForm", loginForm);
    CommonDeclartion.returnValue="redirect:rolewindow" ; // This one not redirecting
    }

    }

    return CommonDeclartion.returnValue;
    }

    ---------------------------------------------------------------------------------------------------------------
    RoleWindow:

    @RequestMapping(value="rolewindow",method=RequestM ethod.POST) // I tried with /rolewindow and GET
    public String fromLoginWindow(@ModelAttribute("loginForm") LoginForm loginForm,BindingResult bindingResult, Model model){

    System.out.println("done..");
    return "smething";
    }

    ---------------------------------------------------------------------------------------------------------------

    Please help me..
    Last edited by sasikumarkrishnasamy; 08-17-2014 at 07:54 PM.

Similar Threads

  1. Need help for controller
    By powerpravin in forum New To Java
    Replies: 0
    Last Post: 04-12-2011, 06:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •