比较EL中的字符串 [英] Comparing strings in EL

查看:110
本文介绍了比较EL中的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为JSP提供一个User对象,并想将用户的属性与给定的String进行比较.我现在正在做的事情如下:

I'm giving a User object to JSP and want to compare an attribute of the user with a given String. What I'm doing right now is the following:

<input type="radio" name="lang" value="ger" <c:if test="${user.comLanguage.equals("ger")}">checked="yes"</c:if>/>German</br>

但是我得到的只是以下异常:

But all I get is the following Exception:

org.apache.jasper.JasperException: /WEB-INF/jsp/library/home.jsp (line: 22, column: 95) equal symbol expected

其中第95列是comLanguage的字母之一.

where column 95 is one of the letters of comLanguage.

这里的正确语法是什么?

What's the correct syntax here?

推荐答案

尝试一下:

<c:if test="${user.comLanguage=='ger'}">

如果满足以下条件,您也可以尝试三元组:

Also you can try ternary if:

${user.comLanguage=='ger' ? 'checked' : ''}

这篇关于比较EL中的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆