java 把url传参的汉字变成%百分号形式,<c:url><c:param>,url提交汉字乱码
·
下面这段代码输出的是url为
http://localhost:8080/news/HelloServlet?hello=%e5%a4%a7%e5%ae%b6%e5%a5%bd&test=%e5%a4%a7%e5%ae%b6%e5%a5%bd
其中<c:url value="http://localhost:8080/news/HelloServlet" var="url">
中的value为提交的url,var表示为url
<c:param name="hello" value="${hello}" />中的name为在下边引用的名字,如${hello},value为静态值,即显示的是${hello}中的hello,但会被转化为%百分号形式,避免url提交汉字出现乱码
这个设置还需要设置tomcat/conf/server.xml中的URLEncoder="urf-8"
黑色头发:http://heisetoufa.iteye.com/
http://localhost:8080/news/HelloServlet?hello=%e5%a4%a7%e5%ae%b6%e5%a5%bd&test=%e5%a4%a7%e5%ae%b6%e5%a5%bd
<body>
<c:url value="http://localhost:8080/news/HelloServlet" var="url">
<c:param name="hello" value="${hello}" />
<c:param name="test" value="${hello}" />
</c:url>
<a href="<c:out value="${url}" />">${hello}</a>
</body>其中<c:url value="http://localhost:8080/news/HelloServlet" var="url">
中的value为提交的url,var表示为url
<c:param name="hello" value="${hello}" />中的name为在下边引用的名字,如${hello},value为静态值,即显示的是${hello}中的hello,但会被转化为%百分号形式,避免url提交汉字出现乱码
这个设置还需要设置tomcat/conf/server.xml中的URLEncoder="urf-8"
黑色头发:http://heisetoufa.iteye.com/
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)