My simple question is why I cant pass non english parameter with different character encoding through a url like this:
http://my-project-name:8080/something?word=علی
however I can send the parameter using a form with post method but I don't wanna do that & I wanna figure out why I can't do it using get method !
Here are my configurations:
In my web.xml I have:
<filter>
<filter-name>EncodingFilter</filter-name>
<filter-class>sys.system.EncodingFilter</filter-class>
<init-param>
<param-name>encodings</param-name>
<param-value>US-ASCII, UTF-8, EUC-KR, ISO-8859-15, ISO-8859-1</param-value>
</init-param>
<init-param>
<param-name>inputEncodingParameterName</param-name>
<param-value>ie</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
here is my servlet:
public class EncodingFilter implements Filter {
@Override
public void destroy() {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
if (request.getCharacterEncoding() == null) {
request.setCharacterEncoding("UTF-8");
}
if (response.getCharacterEncoding() == null) {
response.setCharacterEncoding("UTF-8");
}
chain.doFilter(request, response);
}
@Override
public void init(FilterConfig arg0) throws ServletException {
}
}
my jsp header has set properly:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> ...
when I want to fetch the paramter word in my controller I have a character encoding, here is my controller:
@RequestMapping(value = "something")
public String stopJob(@RequestParam("word") String word) {
... do something
}
the interesting thing is everything has set properly even when I print
request.getCharacterEncoding();
It returns "UTF-8" to me but the "word" is not proper & It's corrupted. is there anyone here who know about this issue ? thanks !