简体   繁体   English

JspWriter类型的方法print(boolean)不适用于参数(void)

[英]The method print(boolean) in the type JspWriter is not applicable for the arguments (void)

Hi I am facing a error named "The method print(boolean) in the type JspWriter is not applicable for the arguments (void) " with my JSP code in GAE. 嗨,我在GAE中遇到了一个名为“类型为JspWriter的方法print(boolean)不适用于参数(void)”的错误。

In line : <%= request.getSession(true).setAttribute("state","firstNumber") %> 在以下行中: <%= request.getSession(true).setAttribute("state","firstNumber") %>

Here is the code: 这是代码:

` `

  <c:when test='${param.event == "NewCall"}'>
      <% 
         Response resp1=new Response();
         CollectDtmf cd= new CollectDtmf(); 
         cd.addPlayText("Welcome. Please enter the first number. Terminate with #");           
         resp1.addCollectDtmf(cd);
      %>
      <%= request.getSession(true).setAttribute("state","firstNumber") %> 
      <% out.println(resp1.getXML()); %>
  </c:when>

` `

Please tell what am I doing wrong here. 请在这里告诉我我在做什么错。 Thanks 谢谢

<%= %> expects an expression, whose value is printed to the JSP's writer. <%= %>需要一个表达式,其值将打印到JSP的编写器中。 The following 下列

<%= foo %>

is thus equivalent to 因此等于

out.print(foo);

request.getSession(true).setAttribute("state","firstNumber")

is an expression whose type is void. 是一个类型为void的表达式。 And you can't print a void. 而且您不能打印空白。

What you want is simply 您想要的只是

<% request.getSession(true).setAttribute("state","firstNumber") %>

But of course, as it has been rehashed countless times, scriptlets should not be used in a JSP. 但是,当然,由于无数次被重新定义,因此不应在JSP中使用scriptlet。 JSPs are view components which should only generate HTML using the JSP EL, the JSTL and other custom tags. JSP是视图组件,仅应使用JSP EL,JSTL和其他自定义标签生成HTML。 Not to mention that setting session attributes is, in general, a bad idea, and is even more a bad idea in a view component, which shouldn't have any side effect other than printing to the JSP writer. 更不用说设置会话属性通常是一个坏主意,在视图组件中更是个坏主意,除了打印到JSP编写器之外,它不会有任何副作用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PrintStream 类型中的方法 println(boolean) 不适用于参数 (void) - The method println(boolean) in the type PrintStream is not applicable for the arguments (void) ArrayList 类型中的 toArray(T[]) 方法<Boolean>不适用于参数 (boolean[]) - The method toArray(T[]) in the type ArrayList<Boolean> is not applicable for the arguments (boolean[]) 声明类型中的方法assertEquals(Object,object)不适用于参数(String,Void) - Method assertEquals(Object, object) in the type Assert is not applicable for the arguments (String, Void) 减少代码:“ VoteService类型中的方法changeVote不适用于参数(无效)” - Cutting down code: “The method changeVote in the type VoteService is not applicable for the arguments (void)” 类型PrintStream的方法printf(String,Object ...)不适用于参数(String,void) - The method printf(String, Object…) in the type PrintStream is not applicable for the arguments (String, void) Integer 类型中的方法 parseInt(String) 不适用于参数(布尔值) - The method parseInt(String) in the type Integer is not applicable for the arguments (boolean) Intent类型的方法putExtra(String,boolean)不适用于参数(String,CarouselDataItem) - The method putExtra(String, boolean) in the type Intent is not applicable for the arguments (String, CarouselDataItem) 类型中的方法不适用于参数 - The method in the type is not applicable for the arguments 类型中的方法不适用于参数 - Method in the type is not applicable to the arguments 类型中的方法不适用于参数 - The method in the type is not applicable for the arguments
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM