在项目当中为了要适应火狐浏览器。在选择日期控件时必须要加入一个ID,因为在firefor中只认ID,必须是通过ID来获取其中的一个对象,才能把所选择的时间加入到
输入框中。项目中采用的是struts标签来做的(为了刷新时保留其中的值)。
大家可能知道通常的做法是(不采用struts标签):
<input type="text" id="sDate" name="sDate" class="dd_text"/>
那么在struts中用property="sDate"
<html:text property="sDate" styleClass="dd_text"></html:text>
它直接翻译成的html为:
<input type="text" name="sDate" class="dd_text"/>里面没有id.
因此我们可以采用styleId属性来给该表单元素设置ID:
<html:text property="sDate" styleId="sDate" styleClass="dd_text"></html:text>
[table]
|struts标签属性对应的html标签属性
|
|property------------name
|
|styleID-------------id
|
|styleClass----------class
|
|Property 指该文件框的名字,与ActionForm Bean中的一个属性相匹配
|
|Disabled 设置或获取控件的状态,true表示禁止
|
|style 指定CSS样式
|
|styleClass 指定附加到该标签上的CSS样式表名字|
[/table]
输入框中。项目中采用的是struts标签来做的(为了刷新时保留其中的值)。
大家可能知道通常的做法是(不采用struts标签):
<input type="text" id="sDate" name="sDate" class="dd_text"/>
那么在struts中用property="sDate"
<html:text property="sDate" styleClass="dd_text"></html:text>
它直接翻译成的html为:
<input type="text" name="sDate" class="dd_text"/>里面没有id.
因此我们可以采用styleId属性来给该表单元素设置ID:
<html:text property="sDate" styleId="sDate" styleClass="dd_text"></html:text>
[table]
|struts标签属性对应的html标签属性
|
|property------------name
|
|styleID-------------id
|
|styleClass----------class
|
|Property 指该文件框的名字,与ActionForm Bean中的一个属性相匹配
|
|Disabled 设置或获取控件的状态,true表示禁止
|
|style 指定CSS样式
|
|styleClass 指定附加到该标签上的CSS样式表名字|
[/table]
本文介绍如何在使用Struts框架时解决火狐浏览器对日期控件的支持问题,通过设置struts标签的styleId属性为控件添加ID,确保能够正确地将所选日期传递给输入框。
1077

被折叠的 条评论
为什么被折叠?



