Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Servlet/JSP/JSF/JavaFX Script  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
reply to topicflat modethreaded modego to previous topicgo to next topicgo to back
作者 该不该用Struts的标签? 困扰我很久的问题~~
binghe996





发贴: 4
于 2006-07-08 08:40 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
方案1:

<%
  News ns=(News)request.getAttribute("SETNEWS");
%>
<html:text property="title" maxlength="50" styleClass="textStyle" value="<%=ns.getTitle()%>"/>

方案2:

<input type="text" maxlength="50" class="textStyle" value="<bean:write name="SETNEWS" property="title"/>"/>
-------------
如果用方案1的话,Struts的标签不能嵌套,只能用 value="<%=ns.getTitle()%>" 来负值;
如果用方案2的话,可以直接用Struts的标签负值.
我的问题是:该不该用Struts的标签呢? 方案1和方案2哪一个更好一些呢?大家平常都是怎么写的?
希望高手们不吝赐教,先谢了!



作者 Re:该不该用Struts的标签? 困扰我很久的问题~~ [Re:binghe996]
Jcat

熊猫的猫



发贴: 266
于 2006-07-08 11:56 user profilesend a private message to usersend email to Jcatreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我觉得应该用,甚至是只能用(至少在我实习的地方是这样规范的)

<%.....%>这种东西(除了在文件头的声明部分)是被禁止使用的!

HTML的标签也是能不用就不用,都用"http://struts.apache.org/tags-html"代替。



编程,游泳,睡觉--SleepingCat
作者 Re:该不该用Struts的标签? 困扰我很久的问题~~ [Re:binghe996]
wz45855360





发贴: 6
于 2006-07-08 14:02 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
同意楼上的说法
<%...%>这个东西在好在jsp页面少用



作者 Re:该不该用Struts的标签? 困扰我很久的问题~~ [Re:binghe996]
binghe996





发贴: 4
于 2006-07-08 15:17 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
楼上的两位还是没有回答出我的问题啊?
如果选用方案1,就必须用<%...%>
如果选用方案2,就必须用<input type="text"/>

哪一个更好呢?



作者 Re:该不该用Struts的标签? 困扰我很久的问题~~ [Re:binghe996]
Jcat

熊猫的猫



发贴: 266
于 2006-07-08 17:19 user profilesend a private message to usersend email to Jcatreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
又想了想,我觉得都不好。我实在很讨厌在jsp中看见<%...%>,文件头除外。

对方案1改进一下或许会更好:
还是结合上EL吧,这样你的代码就可以像这样
<html:text property="title" maxlength="50" styleClass="textStyle" value="${SETNEWS.title}"/>

当然,你必须在forward这个页面文件的Action中(注意,不是要处理这个页面信息的Action),为HttpServletRequest对象set好SETNEWS这个attribute。

感觉这也有点IoC的韵味(有点小题大做了)


Jcat edited on 2006-07-08 17:53

编程,游泳,睡觉--SleepingCat
作者 Re:该不该用Struts的标签? 困扰我很久的问题~~ [Re:binghe996]
hitaco





发贴: 432
于 2006-07-10 23:08 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
只用html作form binding,否则太麻烦。

至于其他的,比如bean,logic,等等,就不必了,可用JSTL+JSP2 EL

通常公司会有相关的要求,保持代码一致。




reply to topicflat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923