Reputation: 414
I m having a html form with input field, so when is used english for the input there is no problem but using chinese words i got some incorrect string in the servlet, what encoding i m suppose to use and how to set it?
in the html form
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
...
<form method="post" action="<%= action %>" accept-charset="UTF-8">
in the servlet
String charset = request.getCharacterEncoding();
// here charset is always null
String shareContent = request.getParameter("content");
For example input : 朋友你好 in servlet come : "æåä½ å¥½"
Any idea?
Upvotes: 1
Views: 974
Reputation: 195269
can you try if this works for you:
request.setCharacterEncoding( "UTF-8 ");
also you may want to add a filter to do the encoding on all request/response.
Upvotes: 1