you need not have the name attribute in the html:form tag. It can get it
from the struts_config file. Do you have setters and getters for all your
attributes in the actionform?
hope that helps.
VA
-----Original Message-----
From: Bill Clinton [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 08, 2001 3:43 PM
To: [EMAIL PROTECTED]
Subject: struts-config.xml question
Hello,
I just am starting out with struts, and I have a question. I
started with this syntax in my test jsp:
<html:form name="questionForm" action="insertQuestion">
<html:text property="questionDesc"/>
</html:form>
and this in my struts-config.xml:
<form-bean name="questionForm"
type="com.companyname.actionform.QuestionForm"/>
but I was getting this error:
javax.servlet.jsp.JspException: Must specify type attribute if name is
specified
#########################
After searching this list's archives, I saw a reply to a similar
question from Craig McClanahan that states:
> If you specify name here, you must also specify type.
>
> If you change this to:
>
> <form:form action="regstep1.do"> The tag will be smart enough
> to figure out what form bean name you want, without
> having to specify it both here and in struts-config.xml.
>
so, to test, I specified the name in my jsp html:form tag so it looked
like this:
<html:form name="questionForm"
type="com.companyname.actionform.QuestionForm" action="insertQuestion">
and this worked.
#########################
But, I don't want to have to list the classnames in the JSPs, so I tried
to follow craigs suggestion. I changed the lines in the JSP to:
<html:form name="questionForm" action="insertQuestion">
and tried this in my struts-config.xml:
<form-bean name="questionForm"
type="com.companyname.actionform.QuestionForm"/>
<action path="/insertQuestion"
type="com.companyname.actionmap.InsertQuestionAction"
name="questionForm"
scope="request"
validate="false">
<forward name="success" path="/strutstest.jsp"/>
</action>
but now I get this error:
javax.servlet.jsp.JspException: Cannot find ActionMappings or
ActionFormBeans collection
I also searched on this error, but the messages I found did not seem to
match my situation.
#######################################
Since it works when I specify both the name and type in the html:form
tag, I am starting to wonder if my struts-config.xml (in my WEB-INF dir)
is being read. Is it enough to put this file in the WEB-INF directory?
Also, when I had the name in my html:form tag and the type in the
form-bean tag, it seemed obvious how these two things were linked (even
thought this was not correct).
When I follow Craig's suggestion, I am unsure how "The tag will be smart
enough to figure out what form bean name you want." Does it use the JSP
name to link to the "path" attribute of the action tag, and link the
name attribute of the action tag to the name attribute of the form-bean tag?
Sorry about the length of this message, but I wanted to try to be as
specific as possible about the problem.
Also, if anyone knows of any good documentation links, I am open to
suggestions. Other than the docs on the apache site, I have only found
www.husted.com , which has lots of useful tips. Any others out there?
Thanks, Bill