html:hidden的使用

本文详细介绍了在Struts框架下如何从JSP页面向Action传递值的两种常见方式。一种是通过FormBean字段进行传递,另一种则是利用request对象进行非FormBean字段的传递。
2007-06-08 14:18

一般来说,我们在使用Struts时,如果要在JSP隐式的传值给Action有两种情况:


1、要传的值是FromBean中的一个字段,你说的情况应该就是这种情况,例如需要在Edit页面中保存theID,在Action中执行Update操作时根据ID来更新数据库的值,你可以这样做:


Jsp中的代码为:<html:hidden property="theID" />


提交后,theID的值就会放到FormBean中的theID中,你就可以通过getTheID()来获得这个值。


2、要传的值不是FromBean中的一个字段:


Jsp中的代码为:


<input type="hidden" name="XXX" value="<%=request.getAttribute(XXX)%>">


当然,你应该在Action中就已经就这个值放到了request中,request.setAttribute("XXX",value);,
然后在Action中你才可以通过request.getParameter("XXX");来取得这个值。

补充一点,request.setAttribute("XXX",value);中,value应该是个String,还有,

<input type="hidden" name="XXX" value="<%=request.getAttribute(XXX)%>">

应该改为


<input type="hidden" name="XXX" value="<%=(String)request.getAttribute(XXX)%>">

 
HTML中,`overflow: hidden` 是一个CSS属性,用于控制元素内容溢出时的显示方式。当元素内容超出其指定的宽度和高度时,设置 `overflow: hidden` 可以使溢出的内容被修剪,并且这些溢出的内容将无法被看到[^2]。 以下是一个简单示例: ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>overflow: hidden示例</title> <style> div { width: 200px; height: 50px; background-color: #eee; border: 1px dotted black; overflow: hidden; } </style> </head> <body> <div> <p>这里的文本内容会溢出元素框</p> <p>这里的文本内容会溢出元素框</p> <p>这里的文本内容会溢出元素框</p> </div> </body> </html> ``` 在上述示例中,`div` 元素的宽度和高度是固定的,当内部的 `p` 标签文本内容超出 `div` 的尺寸时,由于设置了 `overflow: hidden`,溢出的部分将不会显示[^2]。 在移动端,若直接设置 `overflow: hidden` 无效,可在需要隐藏滚动的内容上包裹一层 `div`,并给这个 `div` 设置 `overflow: hidden`。示例代码如下: ```html <body> <div class="hidDiv"> <section class="wrap">隐藏滚动的内容</section> </div> </body> <style> html { width: 100%; height: 100%; } .hidDiv { width: 100%; height: 100%; overflow: hidden!important; } </style> ``` 该示例展示了在移动端隐藏滚动内容的方法,通过包裹 `div` 并设置 `overflow: hidden` 解决了移动端直接设置无效的问题[^1]。 此外,在一些场景中,`overflow: hidden` 还可用于清除浮动。例如,当 `ul` 元素中的 `li` 元素设置了浮动,`ul` 元素本身高度会塌陷,设置 `overflow: hidden` 可以让 `ul` 元素包含浮动的 `li` 元素,避免高度塌陷: ```html <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> ul { background-color: red; overflow: hidden; } li { height: 60px; width: 100px; background-color: gold; float: left; position: relative; } .tag { background-color: blue; width: 40px; height: 40px; position: absolute; right: 0; top: -20px; } </style> </head> <body> <ul> <li>01</li> <li>02 <div class="tag">新品</div></li> <li>03</li> <li>04</li> <li>05</li> <li>06</li> </ul> </body> </html> ``` 此示例中,`ul` 设置 `overflow: hidden` 后可以正常包裹浮动的 `li` 元素,显示出红色背景,避免了因浮动导致的高度塌陷问题[^5]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值