【问题标题】:Spring boot with JSP, getting exception使用JSP进行春季启动,出现异常
【发布时间】:2017-06-18 06:21:51
【问题描述】:

我正在使用 JSP 进行 Spring Boot,当我在我的 jsp 中尝试以下代码时,我遇到了异常:

   <div class="fc-table ctc-fix-111 border-t inner-grid">

        #{if _purchases.isEmpty()}
        <div class="fc-row">

所以我得到以下代码“#{if _purchases.isEmpty()}”的异常

Servlet.service() for servlet [dispatcherServlet] 在路径 [] 的上下文中抛出异常 [/WEB-INF/jsp/subscriptionsTables.jsp (line: 12, column: 10) #{...} is not allowed在模板文本中] 有根本原因

org.apache.jasper.JasperException: /WEB-INF/jsp/subscriptionsTables.jsp (line: 12, column: 10) #{...} is not allowed in template text 在 org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41) ~[tomcat-embed-jasper-8.5.6.jar:8.5.6]

那么有什么方法可以在我的jsp中使用这样的代码,我需要为此添加任何依赖项吗?

【问题讨论】:

    标签: jsp groovy spring-boot


    【解决方案1】:

    这不是 JSP 中 if 的正确语法。这段代码的 sn-p 是 Thymeleaf 中 if 的示例。

    在 JSP 中你应该使用c:if 标签来代替:

    <c:if test="${_purchases.isEmpty()}">
        <div class="fc-row">
        ....
    
    
    </c:if>
    

    【讨论】:

    • 您好,谢谢您的回答,我有以下扩展语句,我可以在 jsp 中转换它吗? #{extends 'main.html' /}
    猜你喜欢
    • 2014-03-14
    • 2016-08-22
    • 2016-05-08
    • 1970-01-01
    • 2020-06-07
    • 1970-01-01
    • 2017-10-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多