真是惭愧,至今也没有通读一遍Struts的教程

  电子教程倒是下了好几本,都是临到用时去翻。一些基本的东西的概念也是模糊的。像<html:link/>的用法。我就记不得了。书上说:

  The html:link tag renders an HTML anchor tag (i.e., a hyperlink). This tag uses a lot of the same common

attributes as described earlier.You have multiple options for rendering the URL of a hyperlink. You can use the

href, action, forward, or page attributes to specify the URL.

 The href attribute is used to specify a full

URL without any knowledge of the web context of this web application.

 The page attribute is used to specify a

web context relative link.

 The action attribute is used to specify a link to an action mapping, as described in the

Struts config file.

 The forward attribute is used to specify a link to a global forward, as described in the Struts

config file.

Tip: TIP: If you are following a Model 2/MVC architecture, then you should use the page attribute and

the href attribute sparingly. In fact, you should almost never use the page attribute. The href

attribute should only be used to link to resources that are not in the current web application. This helps

you separate the controller from the View by not letting the View select the next View directly. Only the

controller should select the next View. Using the action and forward attributes instead forces you

to delegate selection of the next View to the controller.

Here is an example of linking to an action (/html-link.do) with the page attribute:

<html:link page="/html-link.do">

Linking with the page attribute.

</html:link>

Notice that you do not have to specify the web context of the web application. Conversely, if you used the href

attribute, you would have to specify the web context as follows (where the context is struts-exercise):

<html:link href="/struts-exercise-taglib/html-link.do">

Using Href

</html:link>

Obviously, it is better to use the page attribute when you are linking to things in the same web application (thus,

the same context). You can also use the href attribute to create links that are not on the same server as follows:

<html:link

href="http://otherserver/strutsTut/html-link.do">

Using Href

</html:link>

Another way to link to the html-link.do action is to use the action attribute as follows:

<html:link action="/html-link">

Using Action attribute

</html:link>

(转帖)web中下拉列表的几种实现

转自:http://www.matrix.org.cn/resource/article/43/43809.html

Matrix首页 Java文栏 业界新闻 部落格 资源下载 Java 论坛 web中下拉列表的几种实现

wldandan 发表于2005-09-23 作者:wldandan 评价:0/0 评论数:4 点击数:1490 [收藏]

摘要:

总结一下关于web上使用下拉框的情况

本文Matrix永久镜像:http://www.matrix.org.cn/resource/article/43/43809.html

说明:本文可能由Matrix原创,也可能由Matrix的会员整理,或者由

Matrix的Crawler在全球知名Java或者其他技术相关站点抓取并永久

保留镜像,Matrix会保留所有原来的出处URL,并在显著地方作出说明,

如果你发觉出处URL有误,请联系Matrix改正.

总结一下关于web上使用下拉框的情况

从数据库中获得数据List,将数据放到Request里面

        使用setAttribute(”AList”,AList)

A中有2个属性(String id,String value)

1.        使用JSTL的forEach方式

<select name=”xx” ……..>

<c:forEach items="${AList}" var="p" >

        <c:choose>

                <c:when test="${xxx == p.id}">

                        <option value='<c:out value="${p.id}"/>' selected="selected">

                                        <c:out value="${p.value}"/>

                        </option>

                </c:when>

        <c:otherwise>

                        <option value='<c:out value="${p.id}"/>'>

                                <c:out value="${p.value}"/>

                        </option>

                </c:otherwise>

        </c:choose>       

<c:forEach>

</select>

2.        使用struts的标签

<html:select property=”xxx”>

<html:options collection="AList" labelProperty="value" property="id" />

</html:select>

查一下struts的api文档,可以看到select 中选项有3 taglib可以使用。

第一种直接使用把所有选项写在中间。

<html:option value="0-15">0-15</html:option> <html:option value="15-20" >15-20</html:option> <html:option value="20-30" >20-30</html:option> <html:option value="20 or above">30 or above</html:option>

第二种:把选项放在一个Collection中(这里使用List).在实际项目中,更多的是可能数据来源于db,文件等。这种情况用得比较多。

<html:options collection="AList" property="value" labelProperty="label"/>把option放在list中的过程在Action中作处理//prepare the age selector list.List ageList =new ArrayList();ageList.add(new LabelValueBean("0-15","0-15"));ageList.add(new LabelValueBean("15-20","15-20"));ageList.add(new LabelValueBean("20-30","20-30"));ageList.add(new LabelValueBean("30 or above","30 or above"));request.setAttribute("AList",AList);

这里使用了LabelValueBean,可以不用的,象

<html:options collection="AList" labelProperty="value" property="id" />

只要在AList中填入的bean有value和id属性就可以

第三种,把此list 作为Form 的一个属性.

<html:optionsCollection property="AList" />

在Form 中添加AList 的setter和getter. Form中作如下处理。

//the list can be a form property.

f.setAgeList(AList);

1.        从数据库中获得数据,你应该在Action里面取得数据后,将数据放到Request里面

2.        数据取出来后放在一个List或Collection或Map里面,我习惯用List

3.        从List或其它的容器中取数据应该用<html:options> 或<html:optionsCollection>

4.        <html:options> 和<html:optionsCollection>外层必须用<html:select property="">,所以这个属性你必须在FormBean里定义

5.        由于你要用到这些标签,所以你必须定义FormBean

6.       

从Action取数据,以List为例

List list = xxxxx;//从数据库中取得下拉列表中的数据

request.setAttribute("list",list);

在页面显示

<html:form action="xxxx">...<html:select property="xxx"><html:options collection="list" labelProperty="下拉框中显示的内容,一般是name或其它相似属性" property="各选项对应的值,一般是id" /></html:select>...</html:form>

补充一点点:

因为数据你要从 数据库去取, 所以一般在 action 里调用 DAO ,作为 request 的一个属性传到页面上; 这时一般用 <html:options .../> 标签

另外,如果数据不从数据库去取,而是代码固定的,则一般把这种放到 ActionForm 里,作为属性在页面上取,这时一般用 <html:optionsCollection ... />

我来评价此文: 非常好 还行 一般 扔鸡蛋 总得分:0 投票人次:0

→用户评论列表

#7269 评论作者: littlebat 发表时间:2005-12-27 10:34

正准备用它,对于我来说,上面的信息足够了。谢谢。

#6861 评论作者: jctr 发表时间:2005-12-09 03:59

还应该有第三种,Tapestry的实现,其实也不只这三种还有很多很多吧

#5288 评论作者:xuerldx 发表时间:2005-10-25 07:37

还是不错,就是 有点肤浅

#4811 评论作者: highfan 发表时间:2005-10-05 04:46

你可以把collection 作为

actionform 的

一个属性,在 actionform 中 初始化 也可以 ,在 action 中

初始化 也可以。这样更简单。同时减少view和 control 直接的命名依赖。

我们可以在一张活动图上画一个用例和用例的所有扩展

  今天,向umlchina讨论组和argouml用户讨论组发了一封信,请教是否可以在一张活动图上画一个用例和用例的所有扩展。很高兴收到了argouml开发者mvw的回复。他的意见是可以这样做,并且详细解释了用例图中“包括”和“扩展”的关系。从中可以看出argouml开发社区对用户的真诚和友好。这愈发坚定了我使用argouml进行设计的决心。

  附我的信件和mvw的回信:

From: "Michiel van der Wulp" <mvw@tigris.org>  Add to Address Book  Add Mobile Alert 

To: users@argouml.tigris.org

Date: Tue, 27 Dec 2005 09:28:35 +0100

Subject:  Re: [argouml-users] A question about drawing activity diagram for extends usecases

   

Hi Dashing,

 

Nice colourful diagrams!

 

>> Can I draw the activty diagrams of a usecase and

>> all its extends usecase in one activity diagram?

 

Yes. Since the extends are steps that only happen conditionally, it would be nice to show the condition in the diagram, too. You already did this in the other activity diagram in two ways: with a Junction state (the diamond), and with a Guard - I think both are OK. The junction slightly preferred if people that only know flow-charts have to read the diagrams.

 

One other remark on usecases, which seem to be confused by many, is the difference between include and extend.

An include is comparable with a subroutine: it is always executed, and (usually) only pulled out from the main usecase because it is common with other usecases. An extension is something that happens on a condition somewhere along the path.

 

Regards,

Michiel

 

----- Original Message -----

From: Dashing Meng

To: umlchina@yahoogroups.com ; users@argouml.tigris.org ; 炜 张

Sent: Tuesday, December 27, 2005 4:40 AM

Subject: [argouml-users] A question about drawing activity diagram for extends usecases

Hi,

  Can I draw the activty diagrams of a usecase and all its extends usecase in one activity diagram?here is my usecase diagram:

http://www.learndiary.com/pictures/easyDiary/easyDiaryUseCaseDiagram.gif

this is my activty diagram:

http://www.learndiary.com/pictures/easyDiary/PostADiaryactivityDiagram.gif

my unfinished ArgoUML0.18.1 model:

http://www.learndiary.com/pictures/easyDiary/easyDiary.zargo

 

thanks a lot.

搞不懂ultraEdit的汉字编码问题了

用ultraEdit8英文版,在它和eclipse之间复制汉字会成乱码,直接在各自的窗口中编辑同一个文件,不会成乱码;

用ultraEdit11中文版,eclipse用GBK默认保存的汉字,用它打开成乱码。用它编写的汉字保存后,在eclipse中成乱码,在编译后的程序中成乱码。

真是搞不懂了,只有不用ultraEdit11了,使用ultraEDIT8也不要使用粘贴复制功能了。

使写作日记更方便的具体改动

为了鼓励用户交流,鼓励发帖,特别的进行easy to write diary的改进。按实现的重要性排序:

1、当用户撰写成功一个目标的第一篇日记时,就加入了这个目标。以后在写这个目标下的日记时就不必再次加入这个目标了;

2、如果用户在已经退出或完成的目标中写日记完成后,目标自动转为进行中的目标;

3、既要提供用户专门写日记的链接,更要提供用户在相应的帖子中写日记的选择:

1)、在菜单栏中单独建一个最醒目的链接,文字提示为:今天我要写日记。里面为单独写日记的地方,如果一个用户没有加入任何目标,则提示他在主页上加入目标或者创建目标。怎么样判断一个用户没有加入任何目标呢?有两种方法来进行判断:

  (1)、在usergoal表中检测是否有这个用户的进行中的目标项;

  (2)、在user表中添加3个字段,分别为:进行中、退出的、完成的目标数目;

决定采用第(2)种方法,这里需要把userGoal表中的数据转到user表中的上面的3个字段。

2)、在目标的内容上加入添加日记的链接;

3)、在目标的所有日记列表中加入添加日记的链接;

4)、在目标的我的日记列表中加入添加日记的链接;

5)、在日记的内容上加入添加同类日记的链接;

4、完善用户添加目标的过程,新加一页名为:readyToAddGoal.jsp并且把它加入页面类型常量,建议先进行搜索目标的过程,如果用户点击先进行目标的搜索则在同一页进行目标的搜索同时在导航条中保留“准备添加新目标”的链接;如果用户点击“直接撰写新目标”,则正式撰写新目标。

Common conversation-life-food

faint

What do you say to dinning with me at reastaraunt?

Waiter,is there a vacant table?

waiter,bring us the menu.

Do you wish a regular meal or to order from menu?

What will you have to eat?

I am not sure what do your sugguect?

Well,their double cheesebulger is great.

How do you want your sneak?

Menium,please.

加入通过电子邮件取回密码和MD5加密密码的功能

  首先祝大家圣诞节快乐!祝大家天天快乐!

  学习日记开发小组(LDDG)在本着用户至上的原则,在V0.9.0.4的基础上,学习日记又有新功能如下:

  一、忘记密码的用户可以通过注册时填写的邮件地址获得重设密码的信件,然后根据这个信件中提供的用户ID和标记重设密码。流程如下:

  1、用户忘记密码,请求重置密码;

  2、检测用户是否在72小时内请求过重置密码,若是,给出提示消息,中止;否则继续;

  3、系统发一封包括用户ID和随机产生的8位Token到用户注册时留下的信箱,同时记下发送邮件的时间;

  4、系统每隔1小时检测取回密码的用户的邮件发送时间,如果没有超过72小时,则继续检测;如果超过72小时,则删除用户重置密码的记录,用户需要重新请求发送密码;

  5、用户收到重置密码的邮件,点击重置密码的链接,登录到重置密码的页面,用户输入新密码两遍;

  6、如果用户在重置密码页面输入的用户ID和Token都正确并且两次新密码一致,则系统接受新密码,并经MD5加密后,存入数据库,新密码生效,引导用户转往用户登录页面,同时,删除用户重置密码的记录;

  7、如果用户在重置密码页面输入的用户ID和Token有误或两次密码不一致或者密码字符非法,返回重置密码的页面,提示用户错误和重新输入新密码,直到用户输入正确或取消重置密码的过程;

  二、用户在数据库中的密码经过了MD5加密,任何人都无法知道您的密码,使您对自己的帐户安全问题更放心。  

  三、添加游客测试帐户(guest),使游客可以使用注册用户现有的全部功能(但是为了拥有自己的目标体系,建议注册自己的帐号,以后的注册用户会有更多的权限,具体内容暂时保密:))

  四、最新源码下载:

  1、单独的取回密码模块:使用“argouml+eclipse+struts+strutstestcase+junit(测试驱动)”的开发模式,下载地址:

http://www.learndiary.com/download/learndiary_login.zip

  2、在cvs库中下载最新源码:

  1)单独的取回密码模块:

  cvs -d :pserver:learndiary@cvs.tigris.org:/cvs login(密码:123456)

  cvs -d :pserver:learndiary@cvs.tigris.org:/cvs checkout -P learndiary/find_a_way/login

  2)全部完整的网站源码: 

  cvs -d :pserver:learndiary@cvs.tigris.org:/cvs login(密码:123456)

  cvs -d :pserver:learndiary@cvs.tigris.org:/cvs checkout -P learndiary/old

  

  五、本次更新主要参与者:ppig,dashing_meng(全部开发小组成员参见:http://learndiary.tigris.org/servlets/ProjectMemberList)

根据用户提供的rss地址同步更新用户在其它网站的帖子或

  因为大家在网上发帖和写blog多是为了有同道者加入进来讨论。但是学习日记目前没有几个人加入进来,这就形成一个恶性循环-人越少就越没有人。为了解决这个问题,可以提供把日记绑定到用户其它blog或帖子中的功能。也就是说,只要用户在其它网站上发了帖,我们通过定时检验rss地址,可以把用户的帖子复制过来。

  因为这是用户自愿的,所以应该不会侵权,但是,如果,其它网站禁止用户把文章绑到这里来那是用户与其它网站之间的事,与我们无关。

  这种形式,网上好像已经有了。像有个trans系统的雷达新闻系统就是,还有专门抓取其它网站文章的这种网站。

  要实现这个功能的前提是必须引入RSS技术,并且为了兼容于现在的两种主流rss技术,也许应该两种rss标准都要使用。当然,可以先实现大家使用最多的。