通过文档生成器提交发布请求
Document xmlDocument = builder.parse(request.getInputStream());
这里的请求是以POST方式发送的; 但我无法在 servlet 中处理请求。 抛出以下异常,
org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:98)
任何人都可以建议我答案吗?
提前致谢。
Document xmlDocument = builder.parse(request.getInputStream());
Request here is sent as POST;
But I am unable to get the process the request in the servlet.
Below exception is thrown
org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:98)
Can any one please suggest me the answer.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这段Java代码用于解析XML。
此浏览器 JavaScript 代码发送
application/x-www-form-urlencoded
数据。有效负载sessionid=324trt
不是 XML。读取参数的正确方法是 通过参数映射:
This Java code is for parsing XML.
This browser JavaScript code sends
application/x-www-form-urlencoded
data. The payloadsessionid=324trt
is not XML.The correct way to read the parameter would be via the parameter map:
执行 @McDowell 上面建议的操作,并将您的 xml 作为 POST 参数发布。然后读取 servlet 中的参数并执行以下操作 --
Do what @McDowell suggests above and post your xml as a POST parameter. Then read the parameter in your servlet and do this --