valla problemi şu şekilde çözülüyor.
kodu olduğu gibi koyuyorum.
bu web filter
package com.eksera.service;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;
public class CharacterEncodingFilter implements Filter {
private Logger logger = Logger.getLogger(CharacterEncodingFilter.class.getName());
public static final String REQUEST_CHARACTER_ENCODING = "characterEncoding";
private String encoding = null;
public void init(FilterConfig filterConfig) throws ServletException {
encoding = filterConfig.getInitParameter(REQUEST_CHARACTER_ENCODING);
if (logger.isDebugEnabled()) logger.debug("encoding=" + encoding);
}
private String getInitParameter(FilterConfig filterConfig, String parameterName) throws ServletException {
String value = filterConfig.getInitParameter(parameterName);
if (StringUtils.isEmpty(value)) {
throw new ServletException(getClass().getName() + ": " + parameterName + " is required");
}
return value;
}
public void doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain) throws IOException, ServletException
{
request.setCharacterEncoding(encoding);
chain.doFilter(request, response);
}
public void destroy() { }
}
web.xml de <web-app> altına
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>com.eksera.service.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>characterEncoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/servlet/*</url-pattern>
</filter-mapping>
sayfaların page decleration kısmı şöyle olmalı
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
|
browser için <head></head> taglarının arasına ise
|
<META http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
connection url şöyle olmalı
| jdbc:mysql://127.0.0.1:3306/dbname?useUnicode=true&characterEncoding=UTF-8 |
N/A
|