【问题标题】:Jsp scriplets with taglibs带有标记库的 Jsp 脚本
【发布时间】:2012-06-28 10:17:39
【问题描述】:

下面是我的代码 sn-p 我正在使用带有 taglibs 的脚本。

 <display:column title="Modify">
        <%String userType=(String)session.getAttribute("userType");
        if(userType.equalsIgnoreCase("D"))
        {
        %>

     <html:link action="/deleteOwner.do?type=del&owner_id=${data.owner_id}">Delete</html:link> 

     <%} else if(userType.equalsIgnoreCase("A")){%>

        <c:if test="${data.type == 'A'}">  

     <html:link action="/deleteOwner.do?type=del&owner_id=${data.owner_id}">Delete</html:link> 
        </c:if>
                </display:column>

        <%}%>

但我得到了

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 280 in the generated java file
Syntax error, insert "while ( Expression ) ;" to complete DoStatement

【问题讨论】:

    标签: jsp struts jstl displaytag


    【解决方案1】:

    尽量不要将 scriptlet 与 jstl 混合使用。只会让你头疼。而是将 if/else 语句替换为 choose/when/otherwise 语句。

    对于您的 equalsIgnoreCase() 语句,您可以简单地在您的 userType 上调用 fn:toUpperCase 来进行比较。

    使用 EL,您可以使用 ${userType} 提取 userType 参数

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-12
      相关资源
      最近更新 更多