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

  • successView value

    Dear Folk
    I'm so new with spring so i know this question is suck but please help me...this is part of my application-servlet.xml

    Code:
        <bean id="memberFormController" class="com.netplus.qapp.web.MemberFormController">
            <property name="commandName"><value>member</value></property>
            <property name="formView"><value>form</value></property>
            <property name="successView"><value>start.html</value></property>
            <property name="memberManager"><ref bean="memberManager"/></property>
        </bean>
    and this is my controller class
    Code:
        public ModelAndView onSubmit&#40;HttpServletRequest request,
        HttpServletResponse response, Object command,
        BindException errors&#41;
        throws Exception &#123;
            Member member = &#40;Member&#41; command;
            if &#40;request.getParameter&#40;"delete"&#41; != null&#41; &#123;
                mgr.removeMember&#40;member.getId&#40;&#41;&#41;;
            &#125; else &#123;
                member = mgr.saveMember&#40;member&#41;;
            &#125;
    	Map model = new HashMap&#40;&#41;;
            AnswerImpl answer = new AnswerImpl&#40;&#41;;
    	answer.setMemberId&#40;member.getId&#40;&#41;&#41;;
    	model.put&#40;"member", member&#41;;
    	return new ModelAndView&#40;getSuccessView&#40;&#41;,"model",model&#41;;
    .toString&#40;&#41;&#41;;
        &#125;
    once i press submit on my page i don't know why i have got this error

    resource not found /myContext/start.html.jsp

    who added .jsp to my successView........and how can i get rid of it....please help
    Thanks

  • #2
    Do you have any view resolvers defined in your application-servlet.xml file. Spring uses these view resolvers to map an view name to a specific view. I think such a view resolver might be responsible for adding the .jsp suffix.

    Can you post the entire application-servlet.xml file?

    Arjan

    Comment


    • #3
      The view you're setting is a symbolic or logical view name. It is used by the internalresourceviewresolver (you've probably defined this) to retrieve a concrete View object (in thise case a JstlView or InternalResourceView, whichever one you have configured).

      The resourceviewresolver determines what is done with the view name to get to a resource. In this case, you've probably configured the resourceviewresolver with an empty prefix and a '.jsp' suffix, which means you will end up with 'viewname'.jsp as the view.

      Remove the .html from your view name and the .jsp will be called (if nothing else is wrong of course).

      Hope this helps.

      regards
      Alef

      Comment


      • #4
        This is my
        Code:
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" 
            "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
        
        <beans>
            <bean id="memberController" class="com.netplus.qapp.web.MemberController">
                <property name="memberManager">
                    <ref bean="memberManager"/>
                </property>
            </bean>
            
            <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                <property name="viewClass">      
                    <value>org.springframework.web.servlet.view.JstlView</value>
                </property>
                <property name="prefix"><value>/WEB-INF/jsp/</value></property>
                <property name="suffix"><value>.jsp</value></property>
            </bean>
            
            <bean id="urlMapping" 
                class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
                <property name="mappings">
                    <props>
                        <prop key="/members.html">memberController</prop>
                        <prop key="/addMember.html">memberFormController</prop>
                        <prop key="/start.html">qFormController</prop>
        		
                        <prop key="/1.html">qFormController</prop>
                                            
                    </props>
                </property>
            </bean>
        
            <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
                <property name="basename"><value>messages</value></property>
            </bean>
        
            <bean id="memberFormController" class="com.netplus.qapp.web.MemberFormController">
                <property name="commandName"><value>member</value></property>
                <property name="formView"><value>form</value></property>
                <property name="successView"><value>start</value></property>
                <property name="memberManager"><ref bean="memberManager"/></property>
            </bean>
        
            <bean id="qFormController" class="com.netplus.qapp.web.QFormController">
                <property name="commandName"><value>answer</value></property>
                <property name="formView"><value>1</value></property>
                <property name="successView"><value>1</value></property>
                <property name="memberManager"><ref bean="memberManager"/></property>
            </bean>    
        </beans>

        Comment


        • #5
          Thanks Alef Arendsen and huijzer
          I do remove .jsp from my successView and it seem like to work but i got this error at the end.........

          Code:
          javax.servlet.jsp.el.ELException&#58; Unable to find a value for "memberId" in object of class "com.netplus.qapp.hibernate.entity.MemberImpl" using operator "."
          this is my jsp file
          Code:
          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
          
          <%@ include file="/WEB-INF/jsp/taglibs.jsp"%>
          
          
          <html>
          
          <head>
          
          <title>Eyes Inspire 2005</title>
          
          <meta http-equiv="Content-Type" content="text/html; charset=windows-874">
          
          <style>
          
          
          </style>
          
          <link href="file&#58;///E|/max/melt/webpages/main.css" rel="stylesheet" type="text/css">
          
          </head>
          
          
          
          <form method="post" action="<c&#58;url value="/1.html"/>" onsubmit="return validateMember&#40;this&#41;">
          
          
          
                     
          
                                                     
          
                     <input type="hidden" name="memberId" value="$&#123;model.member.memberId&#125;" />
          Thank you very much

          Comment


          • #6
            Try replacing:

            Code:
            <input type="hidden" name="memberId" value="$&#123;model.member.memberId&#125;" />
            with the following line:

            Code:
            <input type="hidden" name="memberId" value="$&#123;member.memberId&#125;" />
            If this doens't help, please post the code to your command object (com.netplus.qapp.hibernate.entity.MemberImpl)

            Comment


            • #7
              first of all, thanks for wasting your time with me :-)
              I do change as your comment but i got this in stead

              Code:
              javax.servlet.jsp.JspTagException&#58; Neither Errors instance nor plain target object for bean name answer available as request attribute
              this is my form controller config

              Code:
                  <bean id="qFormController" class="com.netplus.qapp.web.QFormController">
                      <property name="commandName"><value>answer</value></property>
                      <property name="formView"><value>1</value></property>
                      <property name="successView"><value>1</value></property>
                      <property name="memberManager"><ref bean="memberManager"/></property>
                  </bean>
              I try to comment command class already, but still got same error.
              Thank you

              Comment


              • #8
                I think it doesn't call QFormController that I do config in urlMapping part,,,,,isn't that about .jsp thing? because in web.xml I only map *.html to /action servlet.....if it's right how can i solve this problem?


                Actually, I just want to do chain of question pages that keep memberId along the way till done.....easy isn't it? my first page is register page and 10 pages of question after that....

                Basically, I don't know how to put memberId (like request.setParameter());

                Thanks you very much

                Comment


                • #9
                  Somehow Spring cannot retrieve the object represented by "answer" from your request.

                  Code:
                  <property name="commandName"><value>answer</value></property>
                  This property tells Spring to bind all variables from the form to the answer command. However, you also need to tell Spring what class to use to construct this answer object.

                  Code:
                  <property name="commandClass"><value>x.y.z.Answer</value></property>

                  Comment


                  • #10
                    Thanks for all your help,,,,,i made it finally,,,,and i do fall in love with spring already,,,,,,,,,,,,

                    Comment

                    Working...
                    X