JSP中的多部分表单,Glassfish中的编码问题 [英] Multipart form in JSP, encoding problems in Glassfish

查看:183
本文介绍了JSP中的多部分表单,Glassfish中的编码问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如果我输入Pêche,就会得到Páches。所以,这是编码问题。我尝试了几个想法,没有任何工作。





我还是得到了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-Typecontent =text / html; charset = UTF-8/>
< title> ....< / title>
< / head>
< body>
< form action =< c:url value =/ form / edit/> method =postenctype =multipart / form-data>

< input type =textid =templateNamename =templateName/>
< br />

< input type =submitvalue =Validerclass =button button_blue margin_button_form/>
< / form>
< / body>
< / html>

其他建议?

解决方案

最后,它似乎是一个Glassfish错误: https: //java.net/jira/browse/GLASSFISH-18516



用下面的方法解决了这个问题: new String(s.getBytes( iso-8859-1),UTF-8); https:// stackoverflow。 com / a / 549634/1458542

I'm getting invalid character from my jsp/servlet using Eclipse and Glassfish.

If I enter "Pêche" I get "Pêches". So, this is encoding problem. I tried several thinks and nothing works.

I still get Mojibake.

Here is my servlet code:

String name = (String) request.getParameter("templateName");

Here is my jsp content:

<%@ 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>

Any other suggestion?

解决方案

At the end, it seems to be a Glassfish bug: https://java.net/jira/browse/GLASSFISH-18516

Solved awfully with this: new String (s.getBytes ("iso-8859-1"), "UTF-8"); (https://stackoverflow.com/a/549634/1458542)

这篇关于JSP中的多部分表单,Glassfish中的编码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆