本站首页
管理页面
写新日志
退出
[QQ:172832876] [MSN:lanlanq@hotmail.com]
麒麟在天欢迎您
.:
日期
«
October 2025
»
日
一
二
三
四
五
六
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
.:
我的分类
首页(64)
J2EE(27)
架构设计(1)
休闲时刻(8)
C++/C#(DotNet)(9)
项目管理(8)
Lotus Notes(6)
.:
最新日志
继承ConfigurationSecti
做正确的事,正确的做事[续1]
c# 数据库连接管理类
做正确的事,正确的做事
摄像头控件(C#)选像,拍照,保存不同数
从网上找的 content-type 类
引发类型为“System.Windows
java.security 类 Acc
instanceof
计算日期
.:
显示信息
blog名称:
日志总数:64
评论数量:34
留言数量:3
访问次数:343920
建立时间:2006年3月10日
.:
留言板
签写新留言
我也向往美好的生活
.:
链接
奕友软件
宋传芳的Blog
公告
在属于自己的一片天空中,敲打着键盘,记录下自己感兴趣和认为自己因该回忆的碎片,可能是财富,也可能是不足,过后你会发现你的进步,这就足够。
[J2EE]
struts的配置和使用(1.2)
原创空间
,
软件技术
luckystar
发表于 2006/3/10 9:05:41
以前学习struts的时候整理了一些心得,也是我在学习和使用过程中遇到的问题解决,应该注意的地方 Struts配置 经过几天的努力和朋友的帮助,Struts终于搞清楚了 环境 resin3.0.12+struts1.1 1、 Jsp(视图) 2、 actionForm 3、 action 4、 模型 视图内容: 有标签和html语言组成。 例如: <%@ include file="taglibs.jsp" %> <%-- 登录验证视图 2005/04/27 lanlanq lanlanq@hotmail.com--%> <html:errors/> <html:form action="/Logon.do"> <center> <table border="0" width="100%"> <tr> <th align="right"> <bean:message key="prompt.username"/> </th> <td align="left"> <html:text property="userName" size="15" maxlength="15" /> </td> </tr> <tr> <th align="right"> <bean:message key="prompt.password"/> </th> <td align="left"> <html:password property="password" size="15" maxlength="15" /> </td> </tr> <tr> <td align="right"> <html:submit property="submit" > <bean:message key="button.logon"/> </html:submit> </td> <td align="left"> <html:reset> <bean:message key="button.reset"/> </html:reset> </td> </tr> </table> </center> </html:form> 首先配置一下resin3.0.12 然后再工程目录下的WEB-INF下创建lib文件夹,增加struts的支持类包 然后创建TLD文件 struts-bean.tld struts-html.tld struts-logic.tld 这三个标记库文件 以便在Jsp中进行调用。 然后创建struts-config.xml 内容如下: <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> <!-- This is the Struts configuration file for the "Hello!" sample application --> <struts-config> <!-- ======== Form Bean Definitions =================================== --> <form-beans> <form-bean name="HelloForm" type="hello.HelloForm"/> <form-bean name="logonForm" type="member.forms.LogonForm"/> </form-beans> <!-- ========== Action Mapping Definitions ============================== --> <action-mappings> <!-- Say Hello! --> <action path = "/HelloWorld" type = "hello.HelloAction" name = "HelloForm" scope = "request" validate = "true" input = "/DateSouce/hello.jsp" > <forward name="SayHello" path="/DateSouce/hello.jsp" /> </action> <action path = "/Logon" type = "member.actions.LogonAction" name = "logonForm" scope = "request" validate = "true" input = "/DateSouce/error.jsp" > <forward name="Success" path="/DateSouce/sucess.jsp" /> </action> </action-mappings> <!-- ========== Message Resources Definitions =========================== --> <message-resources parameter="application_ch_CN"/> </struts-config> 这个文件是在运行web服务器是首先要去找的配置文件 其中的 <form-beans> <form-bean name="HelloForm" type="hello.HelloForm"/> <form-bean name="logonForm" type="member.forms.LogonForm"/> </form-beans> 表示jsp文件指定的actionForm文件 其中的 <action-mappings> <!-- Say Hello! --> <action path = "/HelloWorld" type = "hello.HelloAction" name = "HelloForm" scope = "request" validate = "true" input = "/DateSouce/hello.jsp" > <forward name="SayHello" path="/DateSouce/hello.jsp" /> </action> <action path = "/Logon" type = "member.actions.LogonAction" name = "logonForm" scope = "request" validate = "true" input = "/DateSouce/error.jsp" > <forward name="Success" path="/DateSouce/sucess.jsp" /> </action> 表示jsp中调用Html:form中的action=Logon.do文件的映射。 其中的name和actionForm中的name保持一致。 如果validate=”true”表示要执行actionForm的validate错误处理。 <message-resources parameter="application_ch_CN"/> 表示国际标准化,再jsp页面中的文字说明都是通过application文件指定。 创建actionForm时注意,在通过JBuilder生成actionForm时注意属性名和jsp中的属性名字保持一致,然后创建action,得execute方法,进行逻辑处理。
阅读全文(2049)
|
回复(0)
|
编辑
|
精华
发表评论:
昵称:
密码:
主页:
标题:
验证码:
(不区分大小写,请仔细填写,输错需重写评论内容!)
站点首页
|
联系我们
|
博客注册
|
博客登陆
Sponsored By
W3CHINA
W3CHINA Blog 0.8 Processed in 0.027 second(s), page refreshed 144787254 times.
《全国人大常委会关于维护互联网安全的决定》
《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号