HttpServletResponse的encodeRedirectURL()与encodeURL()的差别
来源:互联网 发布:天天快递单打印软件 编辑:程序博客网 时间:2024/05/22 15:36
从Servlet3.0规范看,这两个方法的功能类似,但略有差别,规范是这么描述的:
encodeRedirectURL(java.lang.String url)
Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged.
对给定的url进行编码,以用于sendRedirect方法;如果不需要编码,则直接返回(未经修改的)url。
encodeURL(java.lang.String url)
Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged.
对给定的url,通过加上session ID的方式进行编码;如果不需要编码,则直接返回(未经修改的)url。
都对url附加上jsessionid参数进行了处理,如果需要,则在url的path后面附加上;jsessionid=xxx;如果不需要则直接返回传入的url。
encodeURL在附加jsessionid之前还对url做了判断处理:如果url为空字符串(长度为0的字符串),则将url转换为完整的URL(http或https开头的);如果url是完整的URL,但不含任何路径(即只包含协议、主机名、端口,例如http://127.0.0.1),则在末尾加上根路径符号/。
也就是encodeURL如果进行了编码,则返回的URL一定是完整URL而不是相对路径;而encodeRedirectURL则不对URL本身进行处理,只专注于添加jsessionid参数(如果需要)。
0 0
- HttpServletResponse的encodeRedirectURL()与encodeURL()的差别
- 【转载】response对象 encodeURL与encodeRedirectURL
- 关于request的getSession()、response的encodeRedirectURL(String url) 和encodeURL(String url)
- response encodeRedirectURL encodeURL作用
- response encodeRedirectURL encodeURL作用
- 通俗理解encodeURL() 和 encodeRedirectURL()
- Tomcat的getSession()和encodeRedirectUrl()
- response.encodeURL or encodeRedirectURL and jsessionid
- response encodeRedirectURL encodeURL作用(转)
- response.encodeURL的使用
- response.encodeURL的用法
- response.encodeURL的用法
- response.encodeURL的用法
- servlet的encodeURL()方法
- response.encodeURL的用法
- response.encodeURL的用法
- response.encodeURL的用法
- response.encodeURL的用法
- 调整oracle sga的大小导致 ORA-00851和ORA-00844错误
- 在浏览器中通过bartender,调用条码打印机的active控件代码的实现
- linux 下端口close_wait 过多
- FFmpeg-Android
- hdu2544 最短路
- HttpServletResponse的encodeRedirectURL()与encodeURL()的差别
- /usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h:No such file or directory的解决办法
- XAML和WPF
- 安装ceph遇到 /usr/lib64/ceph/erasure-code/libec_example.so.0.0.0 from install of xxx confilics with xxx
- STL学习(三)vector容器学习
- java自动生成验证码插件-kaptcha
- uvalive3905(扫描法)
- 各种字符串Hash函数比较及实现
- poj 2080 Calendar