关于java-web:关于Web开发编码那些事儿

2次阅读

共计 690 个字符,预计需要花费 2 分钟才能阅读完成。

一个残缺的申请地址

http://[username:password@]www.host.com[/contextPath]/servletPath/pathInfo?name= 中国
contextPath 上下文门路,如果部署在根目录下,则省略上下文门路。

例如:
http://localhost/ 上下文门路 /servlet 门路 / 门路信息?name= 中国

Request URL: http://localhost/**%E4%B8%8A%E4%B8%8B%E6%96%87%E8%B7%AF%E5%BE%84**/*servlet%E8%B7%AF%E5%BE%84*/**%E8%B7%AF%E5%BE%84%E4%BF%A1%E6%81%AF**?name=*%E4%B8%AD%E5%9B%BD*

办法 名称 原始值 浏览器编码后 服务器是否解码 解码后
getContextPath() contextPath 上下文门路 %E4%B8%8A%E4%B8%8B%E6%96%87%E8%B7%AF%E5%BE%84
getServletPath() servletPath servlet 门路 servlet%E8%B7%AF%E5%BE%84 /servlet 门路
getPathInfo() pathInfo 门路信息 %E8%B7%AF%E5%BE%84%E4%BF%A1%E6%81%AF / 门路信息
getQueryString() queryString name= 中国 name=%E4%B8%AD%E5%9B%BD name= 中国

Firefoxchrome 测试,中文字符浏览器采纳 UTF- 8 编码并加 %。

正文完
 0