服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > JAVA > 新手入门 > 基础入门 > 查看文档

struts标签


  struts标签

html:form注意事项

在使用html:form时需指定action属性,特别是在使用
html标签时指定的action应在xml中找得到并且页面显示的actionform
应于action中使用的.do引擎相匹配,否则jsp会出错

struts中jsp基本操作

文件头部需增加的代码
<%@ page contenttype="text/html;charset=gb2312" %>
<%request.setcharacterencoding("gb2312");%>
<%@ taglib uri="/web-inf/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/web-inf/struts-html.tld" prefix="html" %>
<%@ taglib uri="/web-inf/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/web-inf/struts-template.tld" prefix="template" %>
一般信息输出
<bean:write name="[xml中form-bean段的name属性]" property="[该form-bean]成员属性"/>
下拉框输出
注:所有html标签(即需在form中显示的),在使用时都需在<html:form/>容器内部
<html:form action="[为处理请求的页面,如´/hello.do´]" >
<html:select property="[用于传数据的actionform的一个属性,该值作为默认值]" >
<html:options
name="[xml中form-bean段的name属性]"
property="[将actionform的一个属性作为option的value,该属性为collection,]"
labelproperty="[将actionform的一个属性作为option的text,该属性为collection,]"
/>
</html:select>
</html:form>

逻辑叠代器使用
<logic:iterate
id="[自定义的代表封装单条记录标识,该标识应与bean:write中name属性相同]recoreid"
name="[xml中form-bean段的name属性]"
property="[action中具为collection属性名称]"
offset="[显示的偏移量]"
length="[显示记录数]"
>
<bean:write
name="[自定义的代表封装单条记录标识,该标识应与bean:write中name属性相同]recoreid" property="[单条记录所映射的actionform的属性]recordname"/>
</logic:iterate>

扫描关注微信公众号