<script type="text/javascript">
function show(){
var f="#wer中文测试";
f = encodeURIComponent(encodeURIComponent(f));
test.value = f;
var url = "servlet/Test?f="+f;
var rtv = showModalDialog(url,"","dialogWidth:820px; dialogHeight:620px; status:0;help:0;scrolling:auto");
}
</script>
<body><input id="test" value=""> <input type="button" value="TEST" onclick="show()" />
</body>
package com.yourcompany.struts.action;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.yourcompany.struts.form.TestForm; public class TestAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {
TestForm testForm = (TestForm) form; response.setCharacterEncoding("UTF-8"); String name=testForm.getName();
String pwd=testForm.getPwd(); response.setCharacterEncoding("UTF-8");
String myname=request.getParameter("myname");
myname=URLDecoder.decode(myname, "UTF-8");
String mypwd=request.getParameter("mypwd");
mypwd=URLDecoder.decode(mypwd, "UTF-8"); System.out.println(name);
System.out.println(pwd);
System.out.println(myname);
System.out.println(mypwd); request.setAttribute("name", name);
request.setAttribute("pwd", pwd);
request.setAttribute("myname", myname);
request.setAttribute("mypwd", mypwd); return mapping.findForward("go");
}
}

encodeURIComponent的更多相关文章

  1. 结合实例详细介绍encodeURI()、encodeURIComponent()、decodeURI()、decodeURIComponent()使用方法

    在介绍encodeURI().encodeURIComponent().decodeURI().decodeURIComponent()方法前我们需要了解Global对象的概念:   Global(全 ...

  2. 简单明了区分escape、encodeURI和encodeURIComponent

    一.前言 讲这3个方法区别的文章太多了,但是大部分写的都很绕.本文试图从实践角度去讲这3个方法. 二.escape和它们不是同一类 简单来说,escape是对字符串(string)进行编码(而另外两种 ...

  3. js的encodeURIComponent与java的URLEncoder的区别

    js中的encodeURIComponent这个函数和java中的URLEncoder有少数不一样的.如下表格就是区别 ascii java js   + %20 ! %21 ! ' %27 ' ( ...

  4. JS中的decodeURIComponent和encodeURIComponent

    两个函数可以对特定函数生成的密码字符串进行解密操作,就可以生成为未解密的字符串 使用方法: //加密 encodeURIComponent("http://www.cnblogs.com/7 ...

  5. JavaScript URL编码转换函数 encodeURIComponent()

    encodeURIComponent()定义和用法 encodeURIComponent() 函数可把字符串作为 URI 组件进行编码. 语法:encodeURIComponent(URIstring ...

  6. escape,encodeURI,encodeURIComponent的区别

    escape是对字符串进行编码而另外两种是对URL. encodeURI方法不会对下列字符编码 ASCII字母 数字 ~!@#$&*()=:/,;?+'encodeURIComponent方法 ...

  7. escape(), encodeURI()和encodeURIComponent()(转)

      escape(), encodeURI()和encodeURIComponent()是在Javascript中用于编码字符串的三个常用的方法,而他们之间的异同却困扰了很多的Javascript初学 ...

  8. 关于 escape、encodeURI、encodeURIComponent

    参考资料:http://hi.baidu.com/flondon/item/983b3af35b83fa13ce9f3291   http://www.w3school.com.cn/js/jsref ...

  9. javascript中escape()、unescape()、encodeURI()、encodeURIComponent()、decodeURI()、decodeURIComponent()比较

    这些URI方法encodeURI.encodeURIComponent().decodeURI().decodeURIComponent()代替了BOM的escape()和unescape()方法.U ...

  10. js基础篇——encodeURI 和encodeURIComponent

    转自zccst的又一次掉进encodeURIComponent的坑里了 问题: ajax.get ( url+'?k1'=v1+'&k2'=v2+'&k3'=v3, ... ); 由于 ...

随机推荐

  1. django踩坑

    django输入localhost或者127.0.0.1可以进入,输入自己ip报错 结局方案: 首先找到自己的项目的setting.py文件 找到——> ALLOWED_HOSTS = [] 修 ...

  2. 17. PROCESSLIST

    17. PROCESSLIST PROCESSLIST表提供有关正在运行的线程的信息. PROCESSLIST表有以下列: ID :连接标识符. 这是SHOW PROCESSLIST语句的Id列中显示 ...

  3. asp网页无法打开

    环境:Window 2003.IIS6.Framework1.1 .VS2003 一个WebForm项目里面包含一些asp网页  运行后发现asp页面无法访问 提示:无法找到该页 解决方案: 1. [ ...

  4. vs2015 添加行件

    VS自定义项目模板:[2]创建VSIX项目模板扩展 http://jingyan.baidu.com/article/bad08e1e9b08ee09c851210d.html

  5. CI 安装时目录的安全处理

    如果你想通过隐藏 CodeIgniter 的文件位置来增加安全性,你可以将 system 和 application 目录修改为其他的名字,然后打开主目录下的 index.php 文件将 $syste ...

  6. 【网络流】codeforces C. Heidi and Library (hard)

    http://codeforces.com/contest/802/problem/C

  7. hdu 2686最小费用最大流问题

    #include<stdio.h> #include<queue> #include<string.h> using namespace std; #define ...

  8. Cloud BOS平台-自定义用户联系对象

    适用业务场景:新增用户时,联系对象类型默认为:职员.客户.供应商.客户需要增加一类"承运商",类型选择"承运商"时,联系对象只显示相应的承运商."承运 ...

  9. 子串(codevs 4560)

    题目描述 Description 有两个仅包含小写英文字母的字符串A和B.现在要从字符串A中取出k个互不重叠的非空子串,然后把这k个子串按照其在字符串A中出现的顺序依次连接起来得到一个新的字符串,请问 ...

  10. Android应用程序项目结构

    Android应用程序项目结构 [src]:JAVA源代码目录 [gen]:由系统自动生成的JAVA源码文件,不可修改,只可查看和使用 加载的和依赖的类库 [assets]:本地存储文件的一个文件夹 ...