惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
J
Java Code Geeks
雷峰网
雷峰网
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
V
Vulnerabilities – Threatpost
S
Securelist
The Hacker News
The Hacker News
The Register - Security
The Register - Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
G
Google Developers Blog
Hugging Face - Blog
Hugging Face - Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
M
MIT News - Artificial intelligence
AI
AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Schneier on Security
Schneier on Security
N
Netflix TechBlog - Medium
T
The Blog of Author Tim Ferriss
Google DeepMind News
Google DeepMind News
Hacker News - Newest:
Hacker News - Newest: "LLM"
H
Hacker News: Front Page
博客园 - 司徒正美
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog
Microsoft Azure Blog
Microsoft Azure Blog
大猫的无限游戏
大猫的无限游戏
Security Latest
Security Latest
Engineering at Meta
Engineering at Meta
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Threat Research - Cisco Blogs
U
Unit 42
V
V2EX
V2EX - 技术
V2EX - 技术
L
LINUX DO - 最新话题
aimingoo的专栏
aimingoo的专栏
Microsoft Security Blog
Microsoft Security Blog
Recorded Future
Recorded Future
P
Privacy & Cybersecurity Law Blog
美团技术团队
小众软件
小众软件
F
Fortinet All Blogs

博客园 - 往事如风

抓取之近似网页过滤 基情四射的两个css样式 Hadoop 2.4.1 登录认证配置小结 Window中调试HBase问题小结 改了改博客界面 Hbase0.98.4/Hadoop2.4.1整合小结【原创】 Hadoop 2.4.1 Map/Reduce小结【原创】 hadoop的dfs工具类一个【原创】 简化 Hadoop 2.4.1 Eclpse 插件编译【原创】 Hadoop 2.4.1 设置问题小结【原创】 spring的自动装配导致quartz出问题【原创】 spring的单例导致webwork文件上传出现问题【原创】 resin版本导致的webwork2.2.4找不到xwork.xml【原创】 Gel备注【原创】 struts的action直接输出中文备注【原创】 - 往事如风 - 博客园 iframe高度处理【原创】 网上流行的flash切换图片之研究【原创】 FreeMarker生成xml的教训【原创】 图解MyEclipse配置struts+hibernate+spring+FreeMarker【原创】
关于用jsp生成xml的问题【原创】 - 往事如风 - 博客园
往事如风 · 2007-01-22 · via 博客园 - 往事如风

  刚看到群里人说jsp生成的xml用ajax取有问题,由于基本不用jsp做显示,所以只有试验了下,随便写了段测试代码,用ie直接看,很正常,ajax取死活不行,代码如下:

<%@ page language="java" contentType="text/xml; charset=UTF-8" import="java.util.*" pageEncoding="UTF-8"%>
<%
    out.println(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    out.println(
"<root>");
    out.println(
"<node id=\"1\"/>");
    out.println(
"<node id=\"2\"/>");
    out.println(
"</root>");
    out.close();
%>

  很简单的一段代码,输出responseText看了下,正常,奇怪,把responseText用特殊符号夹起来,终于发现前面多了个换行,看看代码,只有pageEncoding后面的%>那可能有点问题,于是把后面的<%提到前面,代码为

<%@ page language="java" contentType="text/xml; charset=UTF-8" import="java.util.*" pageEncoding="UTF-8"%><%
    out.println(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    out.println(
"<root>");
    out.println(
"<node id=\"1\"/>");
    out.println(
"<node id=\"2\"/>");
    out.println(
"</root>");
    out.close();
%>

再用ajax取一下,终于好了,很有意思的问题,记一下。