以下代码会导致错误: c:set var="test" value="test1"/ % String resp = "abc"; resp = resp + ${test}; //in this line I got an Exception. out.println(resp); % 不要在scriptlet.why中使用表达式语言“$ {test}”? 07000 varia
          <c:set var="test" value="test1"/>
      <%
        String resp = "abc"; 
        resp = resp + ${test};  //in this line I got an  Exception.
        out.println(resp);
       %> 
 不要在scriptlet.why中使用表达式语言“$ {test}”?
07000 variables are actually attributes, and by default are scoped at the page context level.
As a result, if you need to access a JSTL variable value in a scriptlet, you can do so by calling the 07001 method on the appropriately scoped object (usually 07002 and request).
resp = resp + (String)pageContext.getAttribute("test"); 
 完整代码
<c:set var="test" value="test1"/>
 <%
    String resp = "abc"; 
    resp = resp + (String)pageContext.getAttribute("test");   //No exception.
    out.println(resp);
  %> 
 更新
But why that exception come to me.
A JSP scriptlet用于包含对页面中使用的脚本语言有效的任何代码片段。 scriptlet的语法如下:
<% scripting-language-statements %>
当脚本语言设置为java时,将scriptlet转换为Java编程语言语句片段,并将其插入到JSP页面的servlet的服务方法中。
在scriptlet中,您可以在Java代码中编写Java代码和$ {test}。
不相关的
> How to avoid Java Code in JSP-Files?
