问题
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