PDA

View Full Version : successView value


roofimon
Jan 24th, 2005, 10:06 AM
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

<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
public ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response, Object command,
BindException errors)
throws Exception {
Member member = (Member) command;
if (request.getParameter("delete") != null) {
mgr.removeMember(member.getId());
} else {
member = mgr.saveMember(member);
}
Map model = new HashMap();
AnswerImpl answer = new AnswerImpl();
answer.setMemberId(member.getId());
model.put("member", member);
return new ModelAndView(getSuccessView(),"model",model);
.toString());
}

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

huijzer
Jan 24th, 2005, 10:17 AM
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

Alef Arendsen
Jan 24th, 2005, 10:18 AM
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

roofimon
Jan 24th, 2005, 10:22 AM
This is my
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://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.InternalResou rceViewResolver">
<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.SimpleUrlH andlerMapping">
<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.ResourceBundle MessageSource">
<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>

roofimon
Jan 24th, 2005, 10:53 AM
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.........

javax.servlet.jsp.el.ELException: Unable to find a value for "memberId" in object of class "com.netplus.qapp.hibernate.entity.MemberImpl" using operator "."

this is my jsp file
<!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:///E|/max/melt/webpages/main.css" rel="stylesheet" type="text/css">

</head>



<form method="post" action="<c:url value="/1.html"/>" onsubmit="return validateMember(this)">







<input type="hidden" name="memberId" value="${model.member.memberId}" />



Thank you very much

huijzer
Jan 24th, 2005, 11:09 AM
Try replacing:


<input type="hidden" name="memberId" value="${model.member.memberId}" />


with the following line:


<input type="hidden" name="memberId" value="${member.memberId}" />


If this doens't help, please post the code to your command object (com.netplus.qapp.hibernate.entity.MemberImpl)

roofimon
Jan 24th, 2005, 11:24 AM
first of all, thanks for wasting your time with me :-)
I do change as your comment but i got this in stead

javax.servlet.jsp.JspTagException: Neither Errors instance nor plain target object for bean name answer available as request attribute

this is my form controller config

<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

roofimon
Jan 24th, 2005, 11:35 AM
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

huijzer
Jan 25th, 2005, 03:46 AM
Somehow Spring cannot retrieve the object represented by "answer" from your request.


<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.


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

roofimon
Jan 25th, 2005, 09:23 PM
Thanks for all your help,,,,,i made it finally,,,,and i do fall in love with spring already,,,,,,,,,,,, :D