JSPCN主页 | JSP空间 | 网站制作 | JSP下载 | JSP论坛 | JSP教程 | 关于JSPCN | 联系我们
JSP虚拟主机,jsp空间,java空间,java虚拟空间,详细请点击进入
做最专业的JSP中文网站 当前位置首页--JSP技术--STRUTS  
文章搜索:
关键字 标题
  
JSP中文网内容管理系统(JCMS)
JSP虚拟主机
网络笔记本
网摘,图片,笔记收藏
虚拟服务器

JSPCN文章目录分类
JSP配置[219]JSP基础[136]
中文问题[69]上传问题[27]
JAVABEAN[46]数据库[212]
文件操作[126]图片声音[17]
JSP其他[57]时间相关[16]
JAVAMAIL[72]STRUTS[144]
开发工具[28]教程系列[157]
JSP实例[89]
JAVA基础[421]APPLET[78]
JAVA网络[179]Applica[115]
Servlet[98]XML[163]
J2ME[257]J2EE[374]
考试相关[63]JAVA线程[90]
EJB[261]Swing[26]
Java API[141]声音图片[28]
异常处理[33]JAVA实例[290]
JAVA类[139]SUN[89]
Hibernate[6]JMX[8]
Spring[34]
本版推荐文章 
本版热点文章 
相关文章链接 
 
form in struts
作者:whilvydy     文章来源:jsp中文网
访问次数:1398次     加入时间:2004年03月06日
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 <action-mappings> and 

</action-mappings>

for example 

<action-mappings>
<action path="/regist" type="net.jspcn.guestbook.LeaveWordAction"
 name="leavewordform" scope="request" input="/guestbook/index.jsp" />
<action path="/overview" forward="/guestbook/hello.jsp" />
<action path="/failed" forward="/guestbook/wuwu.jsp" />
<action path="/display" type="net.jspcn.guestbook.Display" 
name="userf" scope="request" input="/guestbook/index.jsp" />
</action-mappings>



third, you should specify the type of the form name in  the nest of tag <form-beans> and

</form-beans> 

for example

<form-beans>
     <form-bean name="leavewordform" type="net.jspcn.guestbook.LeaveWordForm">
     </form-bean>
     </form-beans> 
    
you must take care whether the form name is same in <ation> and <form-bean>,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 <action> tag

for example

<html:form action="regist.cool" focus="name"

 onsubmit="return validateLeavewordform(this);">



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

like this 

  <html:form action="regist.cool" focus="name"
  
  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 

<html:javascript formName="leavewordform" dynamicJavascript="true"

 staticJavascript="false"/>

formName is the form name in <form-bean> 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 
JSP虚拟主机 | JSP空间 | JSP主机 | JSP双线虚拟主机 | JAVA空间 | JAVA虚拟主机 | 虚拟服务器 | JSP 虚拟服务器 | VPS
Virtual Private Server | JAVA虚拟服务器 | VM服务器 | VHOST | 虚拟操作系统 | JSP论坛 | JAVA论坛 | JSP站点论坛
Copyright © 2002-2005 JSPCN.net. All rights reserved.
JSP中文网    备案序号:蜀ICP备05001583号
成都恒海科技发展有限公司    成都市一环路南二段6号新瑞楼三楼8号