use*_*996 1 java session google-app-engine jsp
嗨,我在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>
Run Code Online (Sandbox Code Playgroud)
`
请告诉我这里做错了什么.谢谢
<%= %>需要一个表达式,其值将打印到JSP的writer.下列
<%= foo %>
Run Code Online (Sandbox Code Playgroud)
因此相当于
out.print(foo);
request.getSession(true).setAttribute("state","firstNumber")
Run Code Online (Sandbox Code Playgroud)
是一个类型为void的表达式.你不能打印出一个空白.
你想要的只是简单
<% request.getSession(true).setAttribute("state","firstNumber") %>
Run Code Online (Sandbox Code Playgroud)
但是,当然,由于它已经无数次重复,因此不应在JSP中使用scriptlet.JSP是视图组件,它们只应使用JSP EL,JSTL和其他自定义标记生成HTML.更不用说设置会话属性通常是一个坏主意,在视图组件中更是一个坏主意,除了打印到JSP编写器之外不应该有任何副作用.
| 归档时间: |
|
| 查看次数: |
7418 次 |
| 最近记录: |