form in struts
[作者]:菩提树下的杨过 [来源]:互联网 [收录时间]:2007-8-1 20:14:03

  one form in struts should take attention the following:




first, you should have an bean extends org.apache.struts.action.ActionForm,(how to

write this bean you can refrence http://jakarta.apache.org/struts/) here,

we assume the name of the bean is test.UserForm;



second, you should declare the form name in the nest of tag and



for example


name="leavewordform" scope="request" input="/guestbook/index.jsp" />


name="userf" scope="request" input="/guestbook/index.jsp" />




third, you should specify the type of the form name in the nest of tag and



for example






you must take care whether the form name is same in and ,struts request

consistency



fourth,in the .jsp(view part) file, if you use struts tag ,the form action should be

assigned with the path property in the tag

for example


onsubmit="return validateLeavewordform(this);">



fifth,if u wanna focus the cursor in the specified text field ,you .jsp file syntax should

like this


here ,name is the text field name



sixth, if u wanna validate the input with javascript,you .jsp file syntax should like this

onsubmit="return validateLeavewordform(this);"

form name leavewordform,captalize the first word,so it's Leavewordform

then with the prefix validate and suffix (this);

not only this u need to call the javascript validate

this following code is also need


staticJavascript="false"/>

formName is the form name in tag

it also need validator-rules.xml and validation.xml file support

use can reference reference

http://www.jspcn.net/more_news.jsp?type_id=3&board_id=25&board_name=Struts



seventh,you must write a action extends org.apache.struts.ation.Action


if u have get some question,please email to me webmaster@jspcn.net

or can visit my web site http://www.jspcn.net/ to search the answer