标签: struts-html

Struts - 所有.tld文件所在的jar文件

我正在开发一个Struts基于Web的应用程序.我是新来的Struts.我想struts-html.tld taglib在我的jsp页面中使用struts提供的.

当我在网上搜索时,我发现在此之前Struts 1.2.9,我们需要.tld手动定位文件.

但现在这些.tld 文件都打包在.jar文件中,我们需要将这些jar文件用作我们项目中的任何其他jar文件.

Q1.所以我的问题是这些.tld文件所在的jar文件.我从Javaranch答案中得知这些.tld文件已打包成struts-taglib.jar文件.我下载了完整的struts库,但没有找到该jar文件.

java struts struts2 struts-html

6
推荐指数
1
解决办法
4万
查看次数

如何将c:forEach标记的循环索引附加到Struts HTML标记属性?

如何将ac:forEach标记的循环索引附加到struts select/text标记的属性?

例如.

<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html"%>

<c:forEach begin="2" end="${pageView.guestCount}" varStatus="gC">
    <div class="section guest-details">
       <html:select property='title_guest<c:out value="${gC.index}"/>'>
          <html:options collection="titles" property="code" labelProperty="value" />
       </html:select>
    </div>
 </c:forEach>
Run Code Online (Sandbox Code Playgroud)

抛出以下错误

javax.servlet.jsp.JspException at org.apache.struts.taglib.html.SelectTag.calculateMatchValues(SelectTag.java:246)

现在,当我调试代码时,<html:select ...它显示当它设置的属性属性时,它的设置"title_guest<c:out value="${gC.index}"/>"可能是上面异常的原因.

另外,我应该提一下,如果我使用上面的格式将循环索引附加到标签的标准html标签属性<select>,代码工作正常.

例如

<c:forEach begin="2" end="${pageView.guestCount}" varStatus="gC">
  <div class="section guest-details">
      <select name='title_guest<c:out value="${gC.index }"/>'>
            <option value="">Select Title</option>
      </select>
  </div>
</c:forEach>
Run Code Online (Sandbox Code Playgroud)

正确输出预期的HTML

我做错了什么,我应该使用EL来创建将填充html:select标签的"property"属性的字符串吗?

UPDATE

以下片段也尝试了,但也没有用 <html:select property="title_guest${gC.index}">

并且,这也不起作用

<c:set var="guestTitle">title_guest${gC.index}</c:set>
<html:select property="${guestTitle}" styleClass="{required: true}">
 <html:options collection="titles" property="code" labelProperty="value" />
</html:select>
Run Code Online (Sandbox Code Playgroud)

jsp struts jstl struts-html

4
推荐指数
1
解决办法
2万
查看次数

Struts html html:text不会关闭input type ="text"标签

我使用struts-html生成表单字段.

例如:

<%@ taglib prefix="html" uri="/WEB-INF/taglibs/struts-html.tld" %>

<html:text property="email" styleId="email" size="44"/>
Run Code Online (Sandbox Code Playgroud)

产生:

<input type="text" name="email" size="44" value="" id="email"> 
Run Code Online (Sandbox Code Playgroud)

如上所示,生成的输入标记未关闭.这导致我的html无效.

struts-html.tld包括:

<tlibversion>1.2</tlibversion>
<jspversion>1.1</jspversion>
<shortname>html</shortname>
<uri>http://struts.apache.org/tags-html</uri>
Run Code Online (Sandbox Code Playgroud)

有谁知道为什么生成的输入没有关闭?有更新的版本吗?哪里可以下载?

我试过用:

<html:html xhtml="true">
Run Code Online (Sandbox Code Playgroud)

其呈现为:

<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"> 
Run Code Online (Sandbox Code Playgroud)

但是,我的输入标签会保持渲染不已闭合.


解:

使用标签:

<html:xhtml/>
Run Code Online (Sandbox Code Playgroud)

注意:如果您像我一样使用Tiles,请直接在包含的jsp中使用它.它不是从您的基本模板文件继承的.

注意:在xhtml模式下,您不能在html:form标记内使用sytleId.这不是问题,因为自动生成id属性来存储bean的名称.

struts struts-html

3
推荐指数
1
解决办法
7535
查看次数

标签 统计

struts ×3

struts-html ×3

java ×1

jsp ×1

jstl ×1

struts2 ×1