文章目录
  1. 1. URL编码
  2. 2. tomcat">tomcat
  3. 3. html
  4. 4. termial编译乱码问题:
  5. 5. 解决mac下maven编译乱码的问题">解决mac下maven编译乱码的问题

URL编码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
### URL中一些字符的特殊含义,基本编码规则如下:   
1、空格换成加号(+)
2、正斜杠(/)分隔目录和子目录
3、问号(?)分隔URL和查询
4、百分号(%)制定特殊字符
5#号指定书签
6、&号分隔参数

### 如果需要在URL中用到,需要将这些特殊字符换成相应的十六进制的值
+ %20
/ %2F
? %3F
% %25
# %23
& %26
  1. javascript对url进行编码的函数有3个,escape,encodeURI,encodeURIComponent 推荐使用最后一个,因为encodeURIComponent()不编码的字符最少,只有5个

    1
    2
    ~!*()'
    encodeURIComponent和decodeURIComponent 可以成对使用

  2. 对应python

    1
    urllib.quoteurllib.unquote

tomcat">tomcat


request.getParameter(“name”)之前会自动做一次解码的工作,而且URIEncoding是默认的ISO-8859-1

html

1
2
3
表单数据会在未编码的情况下进行发送:
<form action="form_action.asp" enctype="text/plain">
</form>

enctype 规定在发送到服务器之前应该如何对表单数据进行编码:
application/x-www-form-urlencoded 在发送前编码所有字符(默认)

multipart/form-data 不对字符编码。在使用包含文件上传控件的表单时,必须使用该值。

text/plain 空格转换为 “+” 加号,但不对特殊字符编码。

```

termial编译乱码问题:

macos:
在MAC OS X 控制台下使用Javac命令编译java程序时,会出现乱码的情况,现提供一种解决办法:
打开终端( terminal)窗口,点击桌面左上方的终端(terminal)–>偏好设置(preferences)–>设置–>高级–>字符编码–>中文(GBK)
或者
-J-Dfile.encoding=UTF-8
javac -encoding utf-8 -classpath D:\web\xxx\WEB-INF\classes;D:\web\xxx\WEB-INF\lib\struts.jar -d D:\web\xxx\WEB-INF\classes xxx.java

解决mac下maven编译乱码的问题">解决mac下maven编译乱码的问题

在.profile下新增: export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
其他方法, 比如在pom.xml里面的maven-compiler-plugin 增加 utf-8测试不成功
maven:
-Dfile.encoding=UTF-8

文章目录
  1. 1. URL编码
  2. 2. tomcat">tomcat
  3. 3. html
  4. 4. termial编译乱码问题:
  5. 5. 解决mac下maven编译乱码的问题">解决mac下maven编译乱码的问题