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
Ïà¹ØÎĵµ£º
<html:html>
<HEAD>
<tiles:insert attribute="header" />
</HEAD>
<body>
<tiles:insert attribute="top" />
<table width="100%" height="400" border="0" align="center"
cellpadding="0" cellspacing="0">
<tr>
<td width="178" ......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration//EN"
"http://jakarta.apache.org/struts/dtds/tiles-config.dtd">
<tiles-definitions>
<definition name="tscs.templet" path="/pa ......
ÒѾ×öºÃµÄÒ»¸öJ2EEÏîÄ¿£¬ÏëÓ¦ÓÃflexÖеÄͼ±í£¬ËùÒÔÏÖÔÚµÄÊ×ÒªÎÊÌâ¾ÍÊÇÈçºÎ°ÑflexǶÈëµ½jspÖУ¬°´ÕÕÍøÉϽéÉܵĽâ¾ö·½°¸×öÁ˸öС²âÊÔ£º
<%@ taglib uri="FlexTagLib" prefix="mm"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
&nbs ......
¸÷ÀàÍøÒ³µ¯´°´úÂë±àд
¡¡
¾³£ÉÏÍøµÄÅóÓÑ¿ÉÄܻᵽ¹ýÕâÑùÒ»Ð©ÍøÕ¾£¬Ò»½øÈëÊ×Ò³Á¢¿Ì»áµ¯³öÒ»¸ö´°¿Ú£¬»òÕß°´Ò»¸öÁ¬½Ó»ò°´Å¥µ¯³ö£¬Í¨³£ÔÚÕâ¸ö´°¿ÚÀï»áÏÔʾһЩעÒâÊÂÏî¡¢°æÈ¨ÐÅÏ¢¡¢¾¯
¸æ¡¢»¶Ó¹â¹ËÖ®ÀàµÄ»°»òÕß×÷ÕßÏëÒªÌØ±ðÌáʾµÄÐÅÏ¢¡£ÆäÊµÖÆ×÷ÕâÑùµÄÒ³ÃæÐ§¹û·Ç³£µÄÈÝÒ×£¬Ö»ÒªÍù¸ÃÒ³ÃæµÄHTMLÀï¼ÓÈ뼸¶ÎJavascript´úÂë¼´¿ÉÊ ......
JSPÖеÄÌø×ª£º
(1). forward()·½·¨
ʹÓõ½javax.servlet.RequestDispatcherÀà
RequestDispatcher rd = getServletContext().getRequestDispatcher("url");
rd.forward(requestVar,requestVar); //´«µÝservletµÄÈë¿Ú²ÎÊý
/*forwardº ......