jspÂÒÂëÎÊÌâ
jspÂÒÂëÎÊÌ⣬ÇóÖú
ÏÂÁ˸ö¼¸ÄêÇ°µÄjspÔ´Â룬ÎÒ×°ÉϺóÒ»Ö±ÓÐÖÐÎÄÂÒÂëÎÊÌ⣬Êý¾Ý¿âÎÒÓÃmysql£¬
²¢ÓÃsql-front²Ù×÷£¬ÔÚÓÃsql-frontµÄʱºòÒÑ°Ñ×Ö·ûÉèÖÃΪgb2312£¬
¶øÇÒÔÚsql-frontÖÐÄÜÕýÈ·ÏÔʾÖÐÎÄ£¬µ«¾ÍÊÇÔÚjspÒ³ÃæÉÏÓÃgetstring·½·¨
µÃµ½ÂÒÂ룬ÎÒÒ²Óùýgetbytes£¨iso-8859-1£©µÈ·½·¨ÊÔ¹ý»¹ÊÇûÓÐÓá£
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" %>
<%@ page pageEncoding="gb2312" %>
ÕâÁ½ÌõÓï¾äÔÚjspÒ³ÃæÒ²¶¼Ð´ÁË
Çó¸ßÈËÏàÖú
ÌáÎÊÕߣº 43385607 - Èý¼¶
×î¼Ñ´ð°¸
°ÑISO-8859-1Âëת»»³ÉGB2312
*/
public static String ISOtoGB(String iso){
String gb;
try{
if(iso.equals("") || iso == null){
return "";
}
else{
iso = iso.trim();
gb = new String(iso.getBytes("ISO-8859-1"),"GB2312");
return gb;
}
}
catch(Exception e){
System.err.print("±àÂëת»»´íÎó£º"+e.getMessage());
return "";
0
»Ø´ðÕߣºÄäÃû 2008-9-11 02:19
ÎÒÀ´ÆÀÂÛ>>
Ò»¡¢Êä³öÖÐÎÄ
1 JSPÒ³ÃæÍ·²¿¼ÓÉÏÓï¾ä£º<%@page contentType="text/html;charset=utf-8"%>
2 SevletÖУºresponse.setContentType("text/html;charset=utf-8");
¶þ¡¢»ñÈ¡±íµ¥Êý¾Ý
¿ÉÒÔÔÚÿ´Î»ñÈ¡µÄʱºòʹÓãº
str=request.getParameter("chStr");
str=new String(str.getBytes("ISO-8859-1"),"utf-8");
µ«ÊÇÕâÖÖ·½Ê½ºÜ·±Ëö£¬Èç¹ûÐèÒª»ñÈ¡µÄÖÐÎıȽ϶࣬¾Í²»Ì«¿ÉÐС£¿ÉÒÔ¿¼ÂÇʹÓÃFilter¡£
ÔÚ%TOMCAT%/webapps/servlets-examples/Web-INF/classes/filtersĿ¼Ï£¬ÓÐÒ»¸öÍêÕûµÄÀý×Ó£¬¿ÉÒÔ½«SetCharacterEncodingFilter.class¿½±´µ½×Ô¼ºÓ¦ÓÃÖУ¬²¢ÉèÖÃweb.xml
<filter>
<filter-name>Set Character Encoding</filter-name>
<Filter-class>SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param&g
Ïà¹ØÎĵµ£º
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> ......
ÒѾ×öºÃµÄÒ»¸öJ2EEÏîÄ¿£¬ÏëÓ¦ÓÃflexÖеÄͼ±í£¬ËùÒÔÏÖÔÚµÄÊ×ÒªÎÊÌâ¾ÍÊÇÈçºÎ°ÑflexǶÈëµ½jspÖУ¬°´ÕÕÍøÉϽéÉܵĽâ¾ö·½°¸×öÁ˸öС²âÊÔ£º
<%@ taglib uri="FlexTagLib" prefix="mm"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
&nbs ......
title: JSP·ÖÒ³¼¼ÊõʵÏÖ
summary:ʹÓù¤¾ßÀàʵÏÖͨÓ÷ÖÒ³´¦Àí
author: evan_zhao
email: evan_zhao@hotmail.com
¡¡¡¡Ä¿Ç°±È½Ï¹ã·ºÊ¹ÓõķÖÒ³·½Ê½Êǽ«²éѯ½á¹û»º´æÔÚHttpSession»òÓÐ״̬beanÖУ¬·Ò³µÄʱºò´Ó»º´æÖÐÈ¡³öÒ»Ò³Êý¾ÝÏÔʾ¡£ÕâÖÖ·½·¨ÓÐÁ½¸öÖ÷ÒªµÄȱµã£ºÒ»ÊÇÓû§¿ÉÄÜ¿´µ½µÄÊǹýÆÚÊý¾Ý£»¶þÊÇÈç¹ûÊ ......
Àý×Ó˵Ã÷£ºÕâÀý×ÓÊÇѧÉú»ù±¾ÐÅÏ¢µÄÊäÈëÒÔ¼°Êä³öÏÔʾ;ÓÐÁ½¸öÒ³Ã棺info.jspºÍshowInfo.jsp£¬Ç°ÕßÊǹ˿ÍÊäÈëµÄÐÅÏ¢Ò³Ã棬¶øºóÕßÊÇ´¦ÀíÐÅÏ¢µÄÒ³Ãæ¡£
info.jsp
<%@page contentType="text/html;charset=gb2312"%>
<HTML>
<HEAD>
<TITLE>ÊäÈëѧ ......
application£ºÈ«¾Ö×÷Ó÷¶Î§£¬Õû¸öÓ¦ÓóÌÐò¹²Ïí£¬¾ÍÊÇÔÚ²¿ÊðÎļþÖеÄͬһ¸öwebApp¹²Ïí£¬ÉúÃüÖÜÆÚΪ£ºÓ¦ÓóÌÐòÆô¶¯µ½Í£Ö¹¡£
session£º»á»°×÷ÓÃÓò£¬µ±Óû§Ê״ηÃÎÊʱ£¬²úÉúÒ»¸öеĻỰ£¬ÒÔºó·þÎñÆ÷¾Í¿ÉÒÔ¼ÇסÕâ¸ö»á»°×´Ì¬¡£ÉúÃüÖÜÆÚ£º»á»°³¬Ê±£¬»òÕß·þÎñÆ÷¶ËÇ¿ÖÆʹ»á»°Ê§Ð§¡£
sessionÊÇÕë¶Ôµ¥¸ö¿Í»§ºÍ·þÎñÆ÷½øÐлỰµÄ  ......