模板 – 播放2:如何比较scala模板中的字符串?
发布时间:2020-12-16 18:54:46 所属栏目:安全 来源:网络整理
导读:我有一个表单对象,我需要检查字段的值是否等于某个字符串 我正在尝试这个,但它没有用 @if(sp.pageType.equals("customreCare")) { //render this specific div } else { //render this other div } 但不幸的是它不起作用,这是什么语法? 解决方法 使用==运算
我有一个表单对象,我需要检查字段的值是否等于某个字符串
我正在尝试这个,但它没有用 @if(sp.pageType.equals("customreCare")) { //render this specific div } else { //render this other div } 但不幸的是它不起作用,这是什么语法? 解决方法
使用==运算符来比较字符串:
@defining("something") {whatToTest => @if(whatToTest == "something"){ There is something } else { There is.... nothing } } 所以在你的情况下(当然要确保在像customreCare这样的条件下没有拼写错误…): @if(sp.pageType == "customreCare") { //render this specific div } else { //render this other div } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |