您好,我在 GAE 中的 JSP 代码中遇到了名为“JspWriter 类型中的方法 print(boolean) 不适用于参数 (void)”的错误。
排队 :<%= request.getSession(true).setAttribute("state","firstNumber") %>
这是代码:
`
<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>
`
请告诉我在这里做错了什么。谢谢
<%= %>
需要一个表达式,其值被打印到 JSP 的编写器。下列
<%= foo %>
因此相当于
out.print(foo);
request.getSession(true).setAttribute("state","firstNumber")
是一个类型为 void 的表达式。而且你不能打印一个空白。
你想要的只是
<% request.getSession(true).setAttribute("state","firstNumber") %>
但是,当然,由于它已经被重复了无数次,所以 scriptlet 不应该在 JSP 中使用。 JSP 是视图组件,只能使用 JSP EL、JSTL 和其他自定义标记生成 HTML。更不用说设置会话属性通常是一个坏主意,在视图组件中更是一个坏主意,除了打印到 JSP 编写器之外,它不应该有任何副作用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)