gpt4 book ai didi

java - "c:choose"标签 : "' 内的非法文本

转载 作者:行者123 更新时间:2023-11-30 17:28:16 27 4
gpt4 key购买 nike

$("#medicine").append('<tr class="hide1 newRow"   id="row'+medCurrentIndex+'">'
+'<td>'+medtype[medCurrentIndex]+'</td>'
+'<td>'+medicineName[medCurrentIndex]+'</td>'
+'<td>'+frequency[medCurrentIndex]+'</td>'
+'<td>'+dose[medCurrentIndex]+'</td>'
+'<td>'+quantity[medCurrentIndex]+'</td>'
+'<td>'+numberofDays[medCurrentIndex]+'</td>'
+'<c:choose>'
+'<c:when test="${role eq 'doctor' }">'
+'<td><button class="btn" type="button" name="edit" value="Edit" onclick="editMedRow('+medCurrentIndex+');">Edit</button></td>'
+'<td><button class="btn" type="button" name="delete" value="Delete" onclick="deleteMedRow('+medCurrentIndex+');">Delete</button></td>'
+'</c:when>'
+'<c:otherwise>'
+'<td><input type="text" id="cost" /></td>'
+'</c:otherwise>'
+'</c:choose>'
+'</tr>');

JSP 的 javaScript 编写此代码是否合法?因为它给我以下错误:

org.apache.jasper.JasperException:

Validation error messages from TagLibraryValidator for c in /WEB-INF/views/prescriptionTemporary.jsp

79: Illegal text inside "c:choose" tag: "'

最佳答案

JSP 中的任何 Java 代码都将在呈现时进行评估。这意味着,服务器将读取 JSP 代码并将开始替换任何 scriptlet 或自定义标记(如 JSTL)以获取必要的 Java 代码。这个例子可以很容易地解释这一点:

<script type="text/javascript">
var x = '${x}';
</script>

或者用JSTL形式:

<script type="text/javascript">
var x = '<c:out value="${x}" />';
</script>

假设 x 是一个值为“Hello World”的请求属性,这将以 HTML 格式生成此输出:

<script type="text/javascript">
var x = 'Hello World';
</script>

在您的情况下,它将尝试将这部分代码转换为其 JSTL 形式:

<c:choose>'
<!-- ^ this character is invalid. There must be a <c:when> right after <c:choose>
v this character is also invalid. There must be a <c:when> right after <c:choose> -->
+'<c:when test="${role eq 'doctor' }">'

简而言之,您不应该尝试从 JavaScript 附加任何类型的 Java 代码(scriptlet、表达式语言、JSTL 等自定义标记等)。

关于java - "c:choose"标签 : "' 内的非法文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23788803/

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