javascript - 向 JSP 传递/公开 VXML 应用程序根文档变量
问题描述
我需要在我的 VXML 应用程序根文档中定义的变量(其他文档修改)可用于 JSP/EL 页面。这里的想法是,基于这些变量的值,我可以向 JSP 添加逻辑以将不同的 VXML 块呈现回 IVR 浏览器。
到目前为止我所尝试的不会产生任何错误。它根本不会在 EL 中呈现预期的 VXML 代码块。我的猜测是我没有在 EL 中正确地取消引用它们。
以下是我尝试过的一些内容。
root.vxml 文档有
..
<var name="promptRetries" expr="''" />
...
开始.jsp:
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml" application="/root.vxml" >
……
<assign name="application.promptRetries" expr="'3'" />
......
<block>
<submit next="${pageContext.request.contextPath}/nextdoc.jsp" />
</block>
nextdoc.jsp
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml" application="/root.xml" >
……
<!-- at this point I can print and see the value of 3 for promptRetries -->
<!-- How can I expose this to JSP to accomplish something like the code below
I have used .equals() and other forms in the EL expression with no luck.
-->
<c:if test="${(application.promptRetries eq 1)} ">
<!-- Setting prompts for 1 retry -->
<catch event="noinput undefined" count="1" >
<audio expr="curPrompt2"/>
<log expr="buildLogStr(ibmCallId, documentName,frmName ,blkName,
'event=noinput count=1 reprompt', '')" />
</catch>
</c:if>
…………
解决方案
在 JSP 中开发 VoiceXML 应用程序时,需要注意有两个执行空间。首先,生成 VoiceXML 的 Java 服务器。其次,执行它的 VoiceXML 浏览器。
您已经有了一个使用 ${variable_name} 语法将数据从 JSP 传递到 VoiceXML 的示例。要将数据从 VoiceXML 传递到 JSP,您需要在提交元素中显式列出要发送的变量:
<submit next="${pageContext.request.contextPath}/nextdoc.jsp" namelist="promptRetries"/>
然后在您的第二个 JSP 页面中,使用
request.getParameter("promptRetries")
访问从浏览器发送的变量。
推荐阅读
- javascript - 从文本框中获取输入并使用该文本重定向以执行谷歌搜索
- javascript - 使用变量作为属性 - 错误:意外的令牌 [
- python - python csv - 如果第 1 列和第 2 列具有特定值,则打印 CSV 值
- reactjs - 无法解析“C:\Users\HP\Desktop\pics\src\components”中的“axios”
- opc-ua - node opcua - 需要关于客户端如何获取给定 UAObject 节点 ID 的所有变量的示例
- reactjs - 最好的方法是过滤内部数据以进行渲染?
- python - setup(name) 和 Extension(name) 有什么关系
- html - 将文本附加到输入字段而不更改其值?
- c++ - 如何获取字符串向量中某个元素的位置,将其用作整数向量中的索引?(= 线程的原始名称)
- r - 创建没有一个数字的随机矩阵