尝试在jsp页面中返回xml数据时出现以下错误: - 此页面包含以下错误: 第1栏第118行的错误:文件末尾的额外内容
但是查看页面源包含xml数据。
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.ModelArrayElement"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.FilterRules"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.ModelsByDivisionRequest"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.ModelsBySubdivisionRequest"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.ModelConfigurationRequest"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.SideBySideComparison"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.SideBySideComparisonRequest"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.SideBySideComparisonGroup"%>
<%@page import="java.util.Arrays"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.AdvantageBasedComparison"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.ConfigurationState"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.AdvantageBasedComparisonRequest"%>
<%@page import="com.forddirect.compare.chrome.generated.Trim"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.AdvantageComparison"%>
<%@page import="java.io.FileInputStream"%>
<%@page import="java.io.InputStream"%>
<%@page import="java.io.FileOutputStream"%>
<%@page import="java.io.OutputStreamWriter"%>
<%@page import="java.io.OutputStream"%>
<%@page import="java.io.File"%>
<%@page import="java.util.ArrayList"%>
<%@page import="javax.xml.ws.BindingProvider"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.AutomotiveConfigCompareService4GPortType"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.ConfigurationElement"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.ReturnParameters"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.PriceSetting"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.MeasurementSystem"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.ConfigurationByStyleIdRequest"%>
<%@page import="java.io.IOException"%>
<%@page import="java.rmi.RemoteException"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.Configuration"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.Locale"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.AccountInfo"%>
<%@page import="com.forddirect.ui.Language.Languages"%>
<%@page import="com.forddirect.compare.chrome.generated.kp.configcompare3.OrderAvailability"%>
<%@page import="com.trilogy.forddirect.util.BuildMarketMode"%>
<%@page import="com.forddirect.compare.chrome.generated.Model"%>
<%@page import="com.forddirect.compare.chrome.generated.Trims.Year.Make"%>
<%@page import="com.forddirect.compare.chrome.generated.Trims.Year"%>
<%@page import="java.util.List"%>
<%@page import="com.forddirect.compare.chrome.generated.TrimEnhanced"%>
<%@page import="com.forddirect.services.compare.chrome.ChromeStylesLoader"%>
<%@page import="com.forddirect.services.compare.chrome.*"%>
<%@page session="false"%>
<%@page import="java.io.ByteArrayOutputStream"%>
<%@page import="javax.xml.bind.JAXBContext"%>
<%@page import="javax.xml.bind.Marshaller"%>
<%@page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<title>Chrome SOAP requests</title>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
function hideAll(){
$('#baseId').hide();
$('#otherIds').hide();
$('#year').hide();
}
$(document)
.ready(
function() {
hideAll();
$('#baseId').show();
$('select[name="requestType"]').change(function(){
if ($(this).val() == "style"){
hideAll();
$('#baseId').show();}
if ($(this).val() == "models"){
hideAll();
$('#year').show();}
if ($(this).val() == "simp"){
hideAll();
$('#baseId').show();
$('#otherIds').show();}
if ($(this).val() == "adv"){
hideAll();
$('#baseId').show();
$('#otherIds').show();}
});
});
</script>
</head>
<body bgcolor="#ffffff">
<form method="get" action="chromeCall.jsp">
<table><tr><td>
Language :</td><td><input type="radio" id="lang" name="lang" value ="EN" checked="checked" />English<input type="radio" id="lang" name="lang" value ="FR" />French</td></tr>
<tr><td>Locale :</td><td><input type="radio" id="locale" name="locale" value ="US" checked="checked" />US<input type="radio" id="locale" name="locale" value ="CA" />Canada</td></tr>
<tr><td>Request Type: </td><td><select id="requestType" name="requestType">
<option value="style">Style Details</option>
<option value="models">Ford Models</option>
<option value="simp">Simple Comparison</option>
<option value="adv">Advantage Comparison</option>
</select></td></tr></table>
<table><tr id="year">
<td>Year: </td><td><input type="text" id="year" name="year" value=""/></td>
</tr>
<tr id="baseId"><td>Base Style Id: </td><td><input type="text" id="baseStyleId" name="baseStyleId" value=""/></td></tr>
<tr id="otherIds"><td>Competitor Ids (semiColon seperated): </td><td><input type="text" id="otherStyleId" name="otherStyleId" value=""/><br/></td></tr>
<!-- <label>Model Id</label><input type="text" id="model" value=""/><br/><input type="submit" id="getModel" value="Get Model Info"><br/>
<label>Make Id</label><input type="text" id="make" value=""/><br/><input type="submit" id="getMake" value="Get Make Info"><br/>
<label>Year</label><input type="text" id="year" value=""/><br/> -->
</table>
<input type="submit" id="getResponse" value="Submit" />
</form>
</body>
</html>
<%!private static final String COUNTRY_CANADA = "CA";
private static final String defaultAccountNumber = "283766";
private static final String defaultAccountSecret = "cc889e87936e4beb";
private static final String defaultCountry = "US";
private static final String defaultLanguage = "EN";
private static final OrderAvailability defaultOrderAvailability = OrderAvailability.RETAIL;
private static final String defaultRuleSet = "chromerules";
private static AccountInfo currentAI = null;
private static String lang = "EN";
public ModelArrayElement getModelsByDivisionId(int divisionId, int modelYear, String language, OrderAvailability availability, AccountInfo ai) throws RemoteException, IOException {
AutomotiveConfigCompareService4GPortType chromeJaxProxyService = ChromeServiceLocator.getChromeServicePort();
List handlerList = ((BindingProvider) chromeJaxProxyService).getBinding().getHandlerChain();
if (handlerList == null) {
handlerList = new ArrayList();
}
SOAPLoggingHandler handler = new SOAPLoggingHandler();
handlerList.add(handler);
((BindingProvider) chromeJaxProxyService).getBinding().setHandlerChain(handlerList);
ModelsByDivisionRequest request = new ModelsByDivisionRequest();
request.setAccountInfo(ai);
FilterRules rules = new FilterRules();
rules.setOrderAvailability(availability);
request.setFilterRules(rules);
request.setDivisionId(divisionId);
request.setModelYear(modelYear);
ModelArrayElement array = chromeJaxProxyService.getModelsByDivision(request);
return array;
}
%>
<%
String lang = request.getParameter("lang") == null ? defaultLanguage : request.getParameter("lang");
String locale = request.getParameter("locale") == null ? defaultCountry : request.getParameter("locale");
String baseStyleId = request.getParameter("baseStyleId");
String otherStyleId = request.getParameter("otherStyleId");
String requestType = request.getParameter("requestType");
String year = request.getParameter("year");
currentAI = getAccountInfo(Languages.valueOf(lang), locale);
}
if (year!=null && "models".equals(requestType)) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
ModelArrayElement modelResponse = getModelsByDivisionId(13, Integer.valueOf(year), lang, defaultOrderAvailability, currentAI);
JAXBContext context = JAXBContext.newInstance(ModelArrayElement.class);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
marshaller.marshal(modelResponse, bytes);
String sb = new String(bytes.toByteArray());
String responseXML = sb.trim();
if(responseXML != null){
response.setContentType("text/xml");
out.println(responseXML.trim().substring("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>".length()));
}
}
if (request.getParameter("make") != null) {
//make make request
}
%>
答案 0 :(得分:1)
您有一个</body>
和</html>
结束标记,但之后您在页面上有更多代码。将该代码移到HTML正文中。