我正在尝试编写一个以 xml 格式返回数据的 servlet。我正在尝试为该特定请求生成一个唯一 ID,一旦我尝试将其添加到uuid
XML 请求中,我总是在浏览器上收到以下错误-
This page contains the following errors:
error on line 2 at column 14: AttValue: " or ' expected
Below is a rendering of the page up to the first error.
这就是我的代码的样子-
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
final String uuid = UUID.randomUUID().toString().replaceAll("-", "");
System.out.println("uuid = " + uuid);
response.setContentType("application/xml");
PrintWriter writer = response.getWriter();
writer.println("<?xml version=\"1.0\"?>");
writer.println("<request uuid = "+uuid+">");
writer.println("<app hash = \"abc\"/>");
writer.println("<app hash = \"def\"/>");
writer.println("</request>");
writer.flush();
}
我上面的代码有什么问题吗?谁能指导我我做错了什么?
谢谢您的帮助!!