EL表达要取的值中包含双引号"" 单引号'' 怎么办
EL表达要取的值中有双引号""也有单引号'' 怎么办?
如 <input type="text" value="${user.name}" 这种情况如果name本包含双引号和单引号咋办,用[]来取貌似都不行啊
<input type="text" value=${user.name}
这样试试看 我记得html属性可以不加双引号。
在后台数据查询出来的时候,要返回页面上的值有单双引号的,你可以写个方法转义一下,应该就行了。像这种一样:
Java code?//特殊字符转为Html public static String toHtml(String s) { s = Replace(s,"&","&"); s = Replace(s,"<","<"); s = Replace(s,">",">"); s = Replace(s,"\t"," "); s = Replace(s,"\r\n","\n"); s = Replace(s,"\n","<br>"); s = Replace(s," "," "); s = Replace(s,"'","'"); s = Replace(s,"\\","\"); return s; } //逆 public static String unHtml(String s){ s = Replace(s,"<br>","\n"); s = Replace(s," "," "); s = Replace(s,"<","<"); s = Replace(s,">",">"); s = Replace(s,"&","&"); return s; }