Java¡¢JSP¡¢HTML¡¢XML±àд¶¼Òª·ûºÏÒÔϱàÂë¹æÔò£¡
1 ËùÓÐµÄ .java|.jsp|.html|.xml Ô´Îļþ¾ùʹÓÃutf-8±àÂë¸ñʽ±£´æµ½ÏµÍ³´ÅÅÌ¡£
È磺ÔÚEclipseÖбà¼Îļþ£¬Ñ¡ÖÐÎļþ´ò¿ªÓÒ¼ü²Ëµ¥Ñ¡ÔñÊôÐÔ£¬½«Îı¾Îļþ±àÂëÉèÖÃΪÆäËû²¢Ñ¡ÔñUTF-8£»Ò²¿ÉÒÔÔÚ
Eclipse——Ê×Ñ¡Ïî——³£¹æ——ÄÚÈÝÀàÐÍÖÐÉèÖø÷ÖÖÎļþµÄȱʡ±àÂ룬ÕâÑùÒÔºóËùÓеÄÎı¾Îļþ¶¼Ê¹ÓÃͳһ±àÂë¡£
2 ÔÚÒ³ÃæÏÔʾÖÐÎÄ·½Ãæ .jspÎļþÖбØÐ뽫Îļþ±àÂë¸ñʽpageEncoding¡¢<@page>Ö¸ÁîÖÐcontentType±àÂë¸ñʽ¡¢<html>µÄ<meta>±êÇ©±àÂë¸ñʽ¶¼ÉèÖÃΪutf-8¡£
È磺
<%@ page language="java" pageEncoding="utf-8"%>
<%@ page contentType="text/html;charset=utf-8"%>
<html>
<head>
<title>ÖÐÎÄÎÊÌâ</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
</html>
×¢Ò⣺ META±êÇ©ÖеıàÂë×Ö·û±ØÐëÊÇ"utf-8"£¬Èç¹û²»¼ÓÖл®Ïߣ¬ÔòÔÚieϳöÏÖÂÒÂëÇé¿ö£¬µ«ieµÄÔÎļþ²é¿´È´ÊÇÖÐÎÄ£¡
3 °Ñ±íµ¥Ìá½»ÄÚÈݵÄ×Ö·û¼¯ÉèΪutf-8£¬ÔÚjsp¡¢servlet»òÕßfilterÖÐʹÓÃrequest.setCharacterEncoding("utf-8");
´ËÐдúÂë±ØÐëдÔÚ×îÇ°Ã棬Èç¹ûÔÚ´ËÇ°½øÐÐÈκÎrequest.getPragrmber()·½·¨¶¼»áʹ×Ö·ûת»»Ê§Ð§£¡
4 Ò³Ã泬Á¬½ÓÁ¬½ÓÖдøµÄºº×ÖÈçÖÐÎÄĿ¼"/ϵͳ/Ò³Ãæ/Ê×Ò³.jsp",ÔòÔÚtomcat/conf/server.xmlÖеÄÅäÖÃÎļþÖмÓÉÏ:useBodyEncodingForURI="true"¼´¿ÉÕý³£Ê¹ÓÃgetParameterÈ¡³öÕýÈ·ÄÚÈÝ¡£È磺
<!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 -->
<Connector port="8080"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000" useBodyEncodingForURI="true"
disableUploadTimeout="true" />
×¢£ºÈç¹ûʹÓÃget·½·¨Ìá½»ÖÐÎIJÎÊýÈç"?name=ÕÅÈý"£¬Ôò±ØÐëʹÓÃencode±àÂëת»»Îª°Ù·ÖºÅ±íʾÀ´´«µÝ£¬È磺
"?name=%E5%BC%A0%E4%B8%89"£¬×¢Òⳤ¶È²»Òª³¬¹ýÁ¬½Ó×Ö·û´®×î´ó³¤¶È¡£
±àÂë·½·¨£º[JavaScript] encodeURIComponent("ÖÐÎÄ");
[Java&JSP] java.net.URLEncoder.encode("ÖÐÎÄ");
½âÂë·½·¨£º[Java
Ïà¹ØÎĵµ£º
ÓõÄÊÇCommonsÉÏ´«×é¼þ£¬ÏÂÔصØÖ·£ºCommons
ÍøÉÏÕÒµÄСÀý×Ӹĵģ¬ÐÞ¸ÄÁ˲¿·Ö´íÎó¡£
1£¬FileUpload.java
package com.fileupload;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.charset.Charset;
import java.util.Iterator;
import java.util.List;
import ja ......
ÓÐʱºòÎÒÃÇ»áÓöµ½java³ÌÐòʹÓÃÄÚ´æ¹ý¶àµÄÇé¿ö£¬ÕâÖÖÇé¿öÒ»°ãÊÇÒòΪ³ÌÐòÓÐÄÚ´æй©£¬ÄÇôÈçºÎ·ÖÎöÊÇ·ñÓÐÄÚ´æй©ÄØ£¿ÆäʵÔÒò±È½Ï¼òµ¥£¬ÏÈÓÃjmapÀ´Éú³ÉÒ»¸ö½ø³ÌµÄÄÚ´æ¿ìÕÕ£¬È»ºóÀûÓÃheapAnalyzer»òÕßMod4JÀ´¶ÔÕâ¸ö¿ìÕÕ½øÐзÖÎö£¬ÕÒµ½ÄÚ´æʹÓÃ×î¶àµÄ¶ÔÏó¡£ÆäʵÓÐÎÞÄÚ´æй©µÄÒ»¸ö±íÏÖ¾ÍÊÇÄÚ´æ·Ö²¼ÊÇ·ñ¾ùÔÈ£¬Èç¹û²»¾ùÔÈ£¬Ò»°ãÀ ......
Ö±½Óͨ¹ýmainÈë¿Ú:
argumentsÉèÖãº-Djava.library.path=¶¯Ì¬¿âËùÔÚĿ¼
ÔÚLinuxÉϵ÷.soÎļþ£º.soÎļþ ±ØÐëÃüÃûΪ£ºlibXXX.so,È磺libJni.so
ÔÚWindowsÉϵ÷.dllÎļþ£º.dllÎļþ ÃüÃû²»Òª¼Ólib,Ö±½ÓÃüÃûΪ£ºXXX.dll È磺Jni.dll
Àý£º
¶¯Ì¬¿â£ºlibJniNassirDecrypt.so »ò JniNassirDecrypt.dll
javaµ÷Óö¯Ì¬¿â´úÂë:
Str ......
----*web.xml *----
----*web.xml *----
<filter>
<filter-name>MyFilter</filter-name>
<filter-class>cray.util.MyFilter</filter-class>
</filter>
<filter-mapping>
<fi ......