Jsp格式编码 [英] Jsp form encoding
问题描述
我有一个jsp页面(让我们说page1.jsp),它有一个html表单,action =page2.jsp。
在page1.jsp和page2.jsp中我有<%@ page contentType =text / html; charset = UTF-8pageEncoding =UTF-8%>
< code>< meta http-equiv =Content-Typecontent =text / html; charset = UTF-8> 如果我在url(get方法)中看到的形式写出希腊字母,就像
HTTP://本地主机:8080 // addProblem.jsp lastNameForm =%CF%84%CF%85%CE%B8%CF%84%CF%85%CE%B8%CF%84%CF%85安培; firstNameForm = & eMa ....
以及来自page2.Jsp并使用<%out.println (用request.getParameter( lastNameForm)); %>
我得到这个αÏÎααÏÎ'
我该怎么办?
因此,您想要解码 更多背景信息以及您可能找到的所有解决方案的详细概述这篇文章有用。 I have a jsp page(let's say page1.jsp) which have an html form with action="page2.jsp".
In page1.jsp and page2.jsp i have If i write greek letters in the form i see in the url(get method) something like that
and from page2.Jsp with the use of i get this Thus, you want to URL-decode The For more background information and a detailed overview of all solutions you may find this article useful. 这篇关于Jsp格式编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! GET
请求参数使用
,另请参阅 UTF-8
字符编码。对于URL解码GET请求参数,您需要在服务器配置中设置字符编码。如何做到这一点取决于有问题的服务器,最好是使用关键字uri encoding。例如,在Tomcat中,您需要为< Connector>
元素的 URIEncoding
code> server.xml
< Connector(...)URIEncoding =UTF-8/> gt ;
HttpServletRequest#setCharacterEncoding()
as Bozho上述仅适用于 POST
请求,其中参数包含在请求正文中而不是URL中。
<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
outside the head section and <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
in the head section.http://localhost:8080//addProblem.jsp?lastNameForm=%CF%84%CF%85%CE%B8%CF%84%CF%85%CE%B8%CF%84%CF%85&firstNameForm=&eMa ....
<% out.println(request.getParameter("lastNameForm")); %>
αÏδαÏδ
What can i do?GET
request parameters using UTF-8
character encoding. For URL-decoding GET request parameters you need to set the character encoding in the server configuration. How to do it depends on the server in question, best is to refer its documentation using the keywords "uri encoding". In for example Tomcat you need to set the URIEncoding
attribute of the <Connector>
element for HTTP requests in the server.xml
, also see this document: <Connector (...) URIEncoding="UTF-8" />
HttpServletRequest#setCharacterEncoding()
as Bozho mentioned only works for POST
requests where the parameters are included in the request body instead of in the URL.