我从使用Eclipse和Glassfish的jsp/servlet中获取无效字符。JSP中的多部分表单,Glassfish中的编码问题
如果我输入“Pêche”,我会得到“PÊches”。所以,这是编码问题。我尝试了几个想法,没有任何工作。
- 我尝试添加的过滤器(Encoding problems in JSP)
- 我试图在web.xml添加JSP属性(Unable to change charset from ISO-8859-1 to UTF-8 in glassfish 3.1)
- 我试图改变由编码request.setCharacterEncoding我的Java代码自字符( “UTF-8”);
- 我尝试添加VM参数(Unable to change charset from ISO-8859-1 to UTF-8 in glassfish 3.1),但我不能因为这个(Eclipse - No server found in Run Configurations)
- 我加入这个 “接受=” UTF-8" 接收字符= “UTF-8”,“我的
- 我在sun-web.xml和glassfish-web.xml中添加了
<parameter-encoding default-charset="UTF-8"/>
我还是得到了Mojibake。
这里是我的servlet代码:
String name = (String) request.getParameter("templateName");
这里是我的JSP内容:
<%@ page pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>....</title>
</head>
<body>
<form action="<c:url value="/form/edit" />" method="post" enctype="multipart/form-data">
<input type="text" id="templateName" name="templateName" />
<br />
<input type="submit" value="Valider" class="button button_blue margin_button_form"/>
</form>
</body>
</html>
任何其他建议?
不工作,我仍然得到奇怪的字符。感谢任何方式;)任何其他想法? – Jon 2013-05-14 10:48:49
无法在servlet中添加这些行;) – Jon 2013-05-14 10:56:57