servlet サーブレット 日本語 文字化け UTF-8 MS932 Shift_JIS EUC-JP
package test; import java.io.IOException; import java.io.PrintWriter; import java.rmi.RemoteException; import javax.ejb.CreateException; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.rmi.PortableRemoteObject; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /* * 日本語の文字化けを回避するサンプル(MS932で出力) * */ public class Test extends HttpServlet { private static final long serialVersionUID = 1L; public void service(HttpServletRequest req, HttpServletResponse res) { PrintWriter pw = null; try { res.setCharacterEncoding("MS932"); res.setContentType("text/html; charset=MS932;"); pw = res.getWriter(); pw.println("あいうえお"); pw.close(); } catch (IOException e) { e.printStackTrace(); } } }
http://goodjob.boy.jp/chirashinoura/id/69.html
作成日: 2006-02-28 20:11:45
最終更新日: 2006-02-28 20:11:45
▲このページの上へ管理人: ぶらざーほわいつ 連絡