当我在chrome中运行localhost时,我收到此错误。
我的Jsp计划:
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@page contentType="application/xml" trimDirectiveWhitespaces="true" %>
<c:choose>
<c:when test='${param.event == "NewCall"}'>
<%
String moderator_no1 =request.getParameter("moderator_no");
String participant_no = request.getParameter("participant_no");
String conference_id = request.getParameter("conference_id");
System.out.println("New call");
out.print("<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><conference moderator=\"true\" caller_onhold_music=\"default\" record=\"true\">"+conference_id+"</conference></response>");
System.out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><conference moderator=\"true\" caller_onhold_music=\"default\" record=\"true\">"+conference_id+"</conference></response>");
session.setAttribute("state", "conferenceStarted");
%>
</c:when>
<c:when test='${(param.event == "Conference" || param.event == "Hangup" || param.event == "Disconnect")}' >
<%
out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?><response></response>");
String session_id = request.getParameter("sid");
out.println(session_id);
System.out.println(session_id);
String called_no = request.getParameter("cid");
System.out.println(called_no);
out.println(called_no);
String actualtime = request.getParameter("total_call_duration");
out.println(actualtime);
System.out.println(actualtime);
String start_time = request.getParameter("start_time");
out.println(start_time);
System.out.println(start_time);
String end_time = request.getParameter("time");
out.println(end_time);
System.out.println(end_time);
%>
</c:when>
</c:choose>
Chrome中的错误输出:
This page contains the following errors:
error on line 2 at column 1: Extra content at the end of the document
Below is a rendering of the page up to the first error.
当我给出event = conference时,我可以在我的日志文件夹中打印null但是在chrome中我得到了上述错误。
请帮帮我。
答案 0 :(得分:0)
原因是,
param.event == "Conference"
首先打印响应
<?xml version="1.0" encoding="UTF-8"?><response></response>
然后打印一些其他变量,如
session_id,called_no,actualtime等。
所以最后xml可能看起来像这样
<?xml version="1.0" encoding="UTF-8"?><response></response> 123456xyz
这将导致error: Extra content at the end of the document
。
您必须决定如何解决此问题。