【问题标题】:Expression Language in JSP not working while i am generating a xml file in Jsp当我在 Jsp 中生成 xml 文件时,JSP 中的表达式语言不起作用
【发布时间】:2017-11-16 14:46:15
【问题描述】:

在我的 Jsp 页面中(name.jsp)

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page contentType="text/xml" %><%@ page isELIgnored="false" %> 
<?xml version="2.5" encoding="UTF-8" standalone="no"?>
<document type="freeswitch/xml">
<section name="configuration">
<configuration name="sofia.conf" description="sofia Endpoint">
  <global_settings>
    <param name="log-level" value="0"/>
    <param name="debug-presence" value="0"/>
    <param name="bind-params" value="transport=udp"/>
  </global_settings>
  <profiles>
     <profile name="external">
        <gateways>

        </gateways>
        <aliases/>
          <domains>
                <domain name="all" alias="false" parse="true"/>
          </domains>
        <settings>


        </settings>

    </profile>
    <profile name="internal">
        <settings>

        </settings>
    </profile>
  </profiles>
</configuration>
<configuration name="ivr.conf" description="IVR menus">
  <menus>
    <menu name="ivr-test" greet-long="say:welcome to neron.  press 1 for sales .   press 2 for support.  press 3 for accounts.  press 4 for me " greet-short="" invalid-sound="say:it was an invalid sound" exit-sound="say:thankyou for contacting us" confirm-macro="" confirm-key="" tts-engine="flite" tts-voice="slt" confirm-attempts="" timeout="10000" inter-digits-timeout="2000" max-failures="3" max-timeouts="" digit-len="4">
      <entry action="menu-exec-app" digits="1" param="bridge sofia/internal/2001@192.168.1.105"/>
      <entry action="menu-exec-app" digits="2" param="bridge sofia/internal/2002@192.168.1.105"/>
      <entry action="menu-exec-app" digits="3" param="bridge sofia/internal/2003@192.168.1.105"/>
    </menu>
  </menus>
</configuration>

它给了我

此页面包含以下错误: 第 1 行第 7 列的错误:XML 声明只允许在开头 文件 下面是出现第一个错误之前的页面渲染。

当我删除 &lt;?xml version="2.5" encoding="UTF-8" standalone="no"?&gt; 时,它工作正常。这个项目完全基于注释而不是 web.xml 文件。你能解决吗?谢谢

【问题讨论】:

  • 我有完全基于注释的项目而不是 web.xml

标签: java xml jsp freeswitch


【解决方案1】:

我经常避免在文本顶部出现空行,这样做:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"
%><%@ page contentType="text/xml" %><%@ page isELIgnored="false"
%><?xml version="2.5" encoding="UTF-8" standalone="no"?>

这是否有帮助是个问题。虽然你可以这样做:

<c:out value='&lt;?xml version="2.5" encoding="UTF-8" standalone="no"?&gt;'
 escapeXml="false"/>

【讨论】:

  • 谢谢亲爱的@joop Eggen,我稍微修改了你的代码并成功了java.sun.com/jsp/jstl/core" prefix="c"%>
猜你喜欢
  • 2012-01-05
  • 1970-01-01
  • 2011-01-11
  • 1970-01-01
  • 1970-01-01
  • 2014-07-10
  • 1970-01-01
  • 2021-04-27
  • 1970-01-01
相关资源
最近更新 更多