Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JSTL相当于jsp标记_Java_Jsp_Web Applications_Jstl_Scriptlet - Fatal编程技术网

Java JSTL相当于jsp标记

Java JSTL相当于jsp标记,java,jsp,web-applications,jstl,scriptlet,Java,Jsp,Web Applications,Jstl,Scriptlet,我有一个搜索应用程序 我的搜索结果在传输对象中都设置为属性 在我的processor java类中,我将TO放在上下文中,如下所示: ctx.putUserData("searchDetailsTO", searchDetailsTO); 除上述对象外,还设置了几个字符串,如下所示: ctx.putUserData("productName", productName); ctx.putUserData("productNameCriteria", productNameCri

我有一个搜索应用程序

我的搜索结果在传输对象中都设置为属性

在我的processor java类中,我将TO放在上下文中,如下所示:

ctx.putUserData("searchDetailsTO", searchDetailsTO);
除上述对象外,还设置了几个字符串,如下所示:

    ctx.putUserData("productName", productName);
    ctx.putUserData("productNameCriteria", productNameCriteria);
    ctx.putUserData("currency", currency);
在我的jsp中,我访问的是:

<jsp:useBean id="searchDetailsTO" scope="session" type="com.domain.SearchDetailsTO" />
它不起作用了

我试着用

<c:when> 

然而,在上面单选按钮的if-else代码中,我开始得到3行3个按钮(9个按钮)


谢谢你的阅读

对于
if..else…
您可以使用

例如:

<c:choose>
      <c:when test="${productNameCriteria eq 'NAME_BEGINS'}">

      </c:when>
      <c:when test="${productNameCriteria eq 'NAME_CONTAINS'}">

      </c:when>
      <c:otherwise>

      </c:otherwise>

</c:choose>

对于
大小
循环

使用循环的
fn:length()
可以获得的大小请参见
c:forEach


希望您可以从答案中操作信息,以获得
if..else…
的确切代码,您可以使用

例如:

<c:choose>
      <c:when test="${productNameCriteria eq 'NAME_BEGINS'}">

      </c:when>
      <c:when test="${productNameCriteria eq 'NAME_CONTAINS'}">

      </c:when>
      <c:otherwise>

      </c:otherwise>

</c:choose>

对于
大小
循环

使用循环的
fn:length()
可以获得的大小请参见
c:forEach


希望您可以处理答案中的信息,以获得确切的代码

首次导入jstl的taglib
第二

  • 对于
    if..else
    使用和
    c:when
    /
    c:others
  • 对于
    对于
    使用
  • 声明变量的用法
  • 要从会话中获取数据,请使用。(将varName替换为要获取的会话数据的名称)
  • 要获得循环中的大小,请使用。(要使用它,您需要导入函数taglib

要使用jstl,您需要在项目中添加两个jar,它们是
jstl.jar
standard.jar



JSTL不会影响java脚本行为。

首先导入JSTL的taglib
第二

  • 对于
    if..else
    使用和
    c:when
    /
    c:others
  • 对于
    对于
    使用
  • 声明变量的用法
  • 要从会话中获取数据,请使用。(将varName替换为要获取的会话数据的名称)
  • 要获得循环中的大小,请使用。(要使用它,您需要导入函数taglib

要使用jstl,您需要在项目中添加两个jar,它们是
jstl.jar
standard.jar


JSTL不会影响java脚本行为。

:不再需要

第一个scriplet初始化局部变量:不再需要了

if/else if/else
:替换为

<c:choose>
    <c:when test="${productNameCriteria == 'NAME_BEGINS'}">

    </c:when>
    <c:when test="${productNameCriteria == 'NAME_CONTAINS'}">

    </c:when>
    <c:otherwise>

    </c:otherwise>
</c:choose>
<c:forEach var="detail" items="${searchDetailsTO.result}">

</c:forEach>

循环前的if测试是不必要的。如果你想保留它,就用它

<c:if test="${!empty searchDetailsTO.result}">

循环:替换为

<c:choose>
    <c:when test="${productNameCriteria == 'NAME_BEGINS'}">

    </c:when>
    <c:when test="${productNameCriteria == 'NAME_CONTAINS'}">

    </c:when>
    <c:otherwise>

    </c:otherwise>
</c:choose>
<c:forEach var="detail" items="${searchDetailsTO.result}">

</c:forEach>

:替换为
${detail.someId}

当然,您的JavaScript不会受到影响。对于JSP(服务器端),JavaScript只是像HTML一样输出的文本。它只在客户端有意义。

:不再需要了

第一个scriplet初始化局部变量:不再需要了

if/else if/else
:替换为

<c:choose>
    <c:when test="${productNameCriteria == 'NAME_BEGINS'}">

    </c:when>
    <c:when test="${productNameCriteria == 'NAME_CONTAINS'}">

    </c:when>
    <c:otherwise>

    </c:otherwise>
</c:choose>
<c:forEach var="detail" items="${searchDetailsTO.result}">

</c:forEach>

循环前的if测试是不必要的。如果你想保留它,就用它

<c:if test="${!empty searchDetailsTO.result}">

循环:替换为

<c:choose>
    <c:when test="${productNameCriteria == 'NAME_BEGINS'}">

    </c:when>
    <c:when test="${productNameCriteria == 'NAME_CONTAINS'}">

    </c:when>
    <c:otherwise>

    </c:otherwise>
</c:choose>
<c:forEach var="detail" items="${searchDetailsTO.result}">

</c:forEach>

:替换为
${detail.someId}


当然,您的JavaScript不会受到影响。对于JSP(服务器端),JavaScript只是像HTML一样输出的文本。它只在客户端才有意义。

谢谢。。如果我遇到任何问题,我会发表评论。谢谢。。如果我遇到任何问题,我会发表评论。