Comparing strings in EL [duplicate]

江枫思渺然 提交于 2019-12-08 15:27:18

问题


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

where column 95 is one of the letters of comLanguage.

What's the correct syntax here?


回答1:


Try this :

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

Also you can try ternary if:

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


来源:https://stackoverflow.com/questions/8355675/comparing-strings-in-el

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!