Java Code inside JSP: How to put double quotes

非 Y 不嫁゛ 提交于 2019-12-13 05:18:14

问题


Our legacy code use Java directly inside JSP. I cannot use EL. I got a problem here:

<jbo:DataSource id="dsyn" appid="AM_Quebec" viewobject="YesnoView1" 
                whereclause='<%="yesno.yn_lang="+locale%>'>

For the whereclause, what I really want is like this:

String yesno_wc = "yesno.yn_lang='" + locale + "'";

Anybody knows how to put the yesno_wc in the where clause? Thanks


回答1:


In Java you can escape double quotes with a backslash.

I might first store that value, here is an example JSP storing the value in a scriptlet, then using a tag with a JSP expression as the value.

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
where
<% String withQuotes = " 'column'='\"value\"' "; %>
<c:out value="<%= withQuotes %>"/>

which produces

where 'column'='"value"'



回答2:


In Java you can escape double quotes with a backslash.

I might first store that value, here is an example JSP storing the value in a scriptlet, then using a tag with a JSP expression as the value.



来源:https://stackoverflow.com/questions/19145328/java-code-inside-jsp-how-to-put-double-quotes

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