Announcement Announcement Module
Collapse
No announcement yet.
successView isnt set Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • successView isnt set

    I keep getting the following error when i do a post from a form which should result in a form controller class getting called but it doesnt.

    this is the error i get when i submit the form:

    javax.servlet.ServletException: successView isn't set
    org.springframework.web.servlet.mvc.SimpleFormCont roller.onSubmit(SimpleFormController.java:340)
    org.springframework.web.servlet.mvc.SimpleFormCont roller.onSubmit(SimpleFormController.java:307)
    org.springframework.web.servlet.mvc.SimpleFormCont roller.processFormSubmission(SimpleFormController. java:248)
    org.springframework.web.servlet.mvc.AbstractFormCo ntroller.handleRequestInternal(AbstractFormControl ler.java:243)
    org.springframework.web.servlet.mvc.AbstractContro ller.handleRequest(AbstractController.java:128)
    org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle(SimpleControllerHandlerAda pter.java:44)
    org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:684)
    org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:625)
    org.springframework.web.servlet.FrameworkServlet.s erviceWrapper(FrameworkServlet.java:386)
    org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:355)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)

    the validator class i have for the form gets called fine and validates the form correctly, however my form controller class's onSubmit method doesnt get called.

    here is the entry in my servlet.xml file for the form controller:

    Code:
    <bean id="loginValidator" class="com.taskmanager.UserLoginValidator"/>    
        <bean id="userLoginFormController" class="com.taskmanager.UserLoginController">
        	<property name="commandName"><value>user</value></property>
        	<property name="commandClass"><value>com.taskmanager.User</value></property>
          	<property name="validator"><ref bean="loginValidator"/></property>
          	<property name="formView"><value>userLogin</value></property>
          	<property name="userdao"><ref bean="userLogin"/></property>  	
        </bean>
    and below is the onSubmit method of my controller class:

    Code:
    	public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception 
    	{
    		System.out.println("test");
    		User user = (User)command;
    		if(user.getUsername() == null && user.getPassword() == null)
    		{
    			return new ModelAndView("userLogin", "incorrectLogin", "false");
    		}
    		
    		else
    		{
    			User loggedInUser = userdao.getUser(user.getUsername(), user.getPassword());
    			if(loggedInUser.getUsername() != null && loggedInUser.getPassword() != null && loggedInUser.getUsertype().equals("Administrator"))
    			{
    				//request.getSession().setAttribute("loggedInUser", loggedInUser);
    				return new ModelAndView("adminLoginSuccess", "loggedInUser", loggedInUser);
    			}
    			if(loggedInUser.getUsername() != null && loggedInUser.getPassword() != null && loggedInUser.getUsertype().equals("Project User"))
    			{
    				//request.getSession().setAttribute("loggedInUser", loggedInUser);
    				return new ModelAndView("normalLoginSuccess", "loggedInUser", loggedInUser);
    			}
    			else
    			{
    				return new ModelAndView("userLogin", "incorrectLogin", "true");
    			}
    		}
    
    		
    	}
    any help would be much appreciated as this problem has been plaguing me for a while now

  • #2
    in addition I have been told that you dont need the successView property in the servlet.xml entry already posted. I do not want to use this property, i will simply reference my view in the new ModelAndView call in the controller class

    Comment


    • #3
      Your onSubmit() for some reason isn't actually overriding the default one from SimpleFormController. I can't tell what that "some reason" is though - the signature seems right. If you are using JDK 5, try adding @Override to before the onSubmit().

      Comment


      • #4
        Views mapped?

        Are the different views (userLogin, adminLoginSuccess, normalLoginSuccess, userLogin) mapped in your view Resolver?

        Btw if your interested in mvc authorization you could also look into the Spring project Acegi. It's AOP based and will do all that logging and sessions for you.

        Comment


        • #5
          I having the same problem while i read this thread... anyhow.. i found my solution... and i m not sure is it ur case too.
          For my case, my "some reason" that made onSubmit()isn't actually overriding the default one from SimpleFormController as refer to manifoldronin is the BindException class that imported automatically by my JDK which is java.net.BindException and not org.springframework.validation.BindException.

          Overriding is not successful while we write our own onSubmit(Object command, java.net.BindException error) to replace the original onSubmit(Object command, org.springframework.validation.BindException error)

          check this out... hope it helps.

          Comment


          • #6
            Originally posted by dannybin View Post
            I having the same problem while i read this thread... anyhow.. i found my solution... and i m not sure is it ur case too.
            For my case, my "some reason" that made onSubmit()isn't actually overriding the default one from SimpleFormController as refer to manifoldronin is the BindException class that imported automatically by my JDK which is java.net.BindException and not org.springframework.validation.BindException.

            Overriding is not successful while we write our own onSubmit(Object command, java.net.BindException error) to replace the original onSubmit(Object command, org.springframework.validation.BindException error)

            check this out... hope it helps.
            Thank you very much it works

            Comment

            Working...
            X