在jsp文件中使用双引号的简单错误 [英] simple error due to use of double quotes in a jsp file

查看:422
本文介绍了在jsp文件中使用双引号的简单错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网络应用程序中的JSP文件中有以下代码行,这个代码发生错误:

  jsp:setProperty name =dbproperty =userNamevalue =<%= request.getParameter(userName)%>/> 

我得到的错误信息是:



< blockquote>

org.apache.jasper.JasperException:
/loginbean.jsp(6,59)属性值
request.getParameter(userName)是
引用与$$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ b $ p code>'(单引号)或(双引号)需要以转义序列 \\ \\ (反斜杠)如果要使用。



但是,当我尝试使用双引号(用户名)反斜杠,我立即得到以下错误 - 非法字符\92-未封闭字符串文字



如何解决此问题?

解决方案

您应该在参数上使用单引号,即:

  value ='<%= request.getParameter(userNa我)%>'

或设置 org.apache.jasper .compiler.Parser.STRICT_QUOTE_ESCAPING 参数为 false ,如下所述:



http://blogs.sourceallies.com/2009/10/strict- quote-escaping-in-tomcat /


I have the following line of code in a JSP File in my web app that is giving an error:

<jsp:setProperty name="db" property="userName" value="<%=request.getParameter("userName")%>"/>

The error message that I get is:

org.apache.jasper.JasperException: /loginbean.jsp(6,59) Attribute value request.getParameter("userName") is quoted with " which must be escaped when used within the value

What I read on some sites is that characters like ' (single quote) or " (double quote) need to be prefixed with an escape sequence \ (backslash) if they are to be used.

However, when I try and prefix the double quotes (around the word userName) with backslash, I immediately get the following error- "Illegal Character \92- Unclosed String Literal"

How do I resolve this problem?

解决方案

You should use single quotes on the value parameter, ie:

value='<%=request.getParameter("userName")%>'

or set the org.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING parameter to false as described here:

http://blogs.sourceallies.com/2009/10/strict-quote-escaping-in-tomcat/

这篇关于在jsp文件中使用双引号的简单错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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