gpt4 book ai didi

java - foreach 中的 Struts 2 URL 参数

转载 作者:行者123 更新时间:2023-11-29 04:04:43 25 4
gpt4 key购买 nike

有人可以向我解释为什么以下代码会导致错误:根据 TLD 或标记文件中的属性指令,属性值不接受任何表达式。每当我尝试为 URL 参数动态设置值时,它总是会中断。

<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<c:forEach var="v" items="${files}">
${v} <a href='<s:url action="DeleteFile"><s:param name="fileName" value="${v}" /></s:url>'>Delete</a><br />
</c:forEach>

我正在使用 Struts 2 和最新版本的 Java。任何帮助将不胜感激。

最佳答案

您正在混合使用 JSTL 标记(foreach)和 Struts 标记(s 参数)。虽然可以让他们一起工作,但为什么要惹麻烦呢?

使用 struts iterator 标签并转储 foreach。

详见 http://struts.apache.org/2.0.14/docs/iterator.html

理论上,原生 struts 2 标签可以用 JSTL 完成所有事情,因此您的应用程序可能根本不需要 JSTL。

关于java - foreach 中的 Struts 2 URL 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/694136/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com