在服务器端,数据输出码表指定 eg
来源:互联网 发布:sqlserver truncate 编辑:程序博客网 时间:2024/04/29 06:17
package cn.itcast.response;
import java.io.IOException;
import java.io.OutputStream;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ResponseDemo1 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String data = "中国";
response.setHeader("content-type", "text/html;charset=UTF-8");
OutputStream out =response.getOutputStream();
byte b[] = data.getBytes("UTf-8");
out.write(b);
private void test2(HttpServletResponse response) throws IOException,
UnsupportedEncodingException {
String data = "中国";
OutputStream out = response.getOutputStream();
response.setHeader("content-type", "text/html;charset=utf-8");
out
.write("<meta http-equive='Content-type' content='text/html;charset=utf-8'>"
.getBytes());
out.write(data.getBytes());
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
import java.io.IOException;
import java.io.OutputStream;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ResponseDemo1 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String data = "中国";
response.setHeader("content-type", "text/html;charset=UTF-8");
OutputStream out =response.getOutputStream();
byte b[] = data.getBytes("UTf-8");
out.write(b);
}
private void test4(HttpServletResponse response) throws IOException,
UnsupportedEncodingException {
//用字符流输出数据
String data = "中国";
response.setHeader("content-type", "text/html;charset=UTF-8");
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
out.write(data);
}
private void test2(HttpServletResponse response) throws IOException,
UnsupportedEncodingException {
String data = "中国";
OutputStream out = response.getOutputStream();
response.setHeader("content-type", "text/html;charset=utf-8");
out
.write("<meta http-equive='Content-type' content='text/html;charset=utf-8'>"
.getBytes());
out.write(data.getBytes());
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
- 在服务器端,数据输出码表指定 eg
- java解析PDF文件,并获取到指定数据.Eg
- 服务器端输出 JSON 格式数据
- 服务器端输出 JSON 格式数据
- 小帆在网页输出指定表中的所有数据
- encienqi-----服务器端输出 JSON 格式数据
- eg
- 黑马程序员_Ajax中使用XML(从服务器端输出XML格式数据,在模版页接收数据)
- 在指定位置输出字符串
- js在指定位置输出
- 在控制台指定位置输出
- 指定码表读写字符
- Ascll码表中的数据对应(可用在SQL中)
- ServletContext(不同用户在服务器端共享数据)
- 安卓在服务器端设置数据
- 8086汇编在指定页、指定行、指定列、指定颜色、输出指定字符(80*25)
- 8086汇编在指定页、指定行、指定列、指定颜色、输出指定字符
- JSON学习(三) --服务器端输出JSON格式数据
- 关于webservice和三方调接口的心得
- MapReduce中Reducer与reduce的关系
- 使用ZendEncode编译PHP程序
- CIRCOS教程翻译 1.3 ——染色体的变化
- FastReport.Net 2013.2更新概要
- 在服务器端,数据输出码表指定 eg
- 从KeychainItemWrapper到SSkeychain
- android socket通信
- extjs -- checkbox radio
- 当优美的C#与Unity3D结合时开发游戏变的超Esey(一)必须掌握的C#100个基本点。
- MyBatis学习(1)
- hibernate 映射文件中id 及id Generator的详解
- HDU 3887 Counting Offspring (树状数组)
- 【技术类】【且听我说“镶嵌数据集”】8、影像存储方式介绍