如何在Play框架的Scala模板的if块中添加多个“ OR”和“ AND”条件

时间:2019-12-09 10:52:50

标签: scala playframework

messageViewer.scala.html

@(formData: Map[String, String] )
<!DOCTYPE html>
<html>
    <head lang="sv">
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>Java Play - Scala Template</title>
    </head>
    <body>
        @if(formData.get("nockOutRuleStatus1").equals("SUBMITTED") && formData.get("nockOutRuleStatus2").equals("APPROVED")){
            //This statement should execute. But it is not executed.
            <button type="button" class="btn btn-default btn-lg hide-element" id="openSuccessModalBtn" data-toggle="modal" data-target="#successModal">Success</button>
        }
        @if(formData.get("nockOutRuleStatus1").equals("REJECTED") || formData.get("nockOutRuleStatus2").equals("AUTO-REJECTED")){
            <button type="button" class="btn btn-default btn-lg hide-element" id="openErrorModalBtn" data-toggle="modal" data-target="#errorModal">Error</button>
        }
    </body>
</html>

从我的Java控制器( messageCtrl.java ),我正在传递地图类型formData。

Map<String, String> formData = new HashMap<String, String>();
formData.put("nockOutRuleStatus1","SUBMITTED");
formData.put("nockOutRuleStatus2","APPROVED");
return ok(messageViewer.render(formData));

但是第一个IF块中的语句未执行。

0 个答案:

没有答案