I am building web application using
- Spring MVC
- Spring Security
- Hibenate
- MySQl
I want to add internationalization support to my application.e.g. I want to store and retrive japanese characters to mySQL db using Hibernate.
I have set DB charset to UTF-8 and also added property to hibernate-cfg.xml
property name="hibernate.connection.characterEncoding">UTF-8
I have done simple POC in which from java file , I am able to declare some string variable with japanese characters and they are successfully inserted into DB and search by japanese characters is also working fine.
But when on JSP file , i fill up form, all field value are passed to controller in form of POJO, and all japansese characters in POJO's field are sutomatically converted into numerical character references as mentioned in below example,
CreateUser.jsp
<form:form method="post" commandName="userModel">
<%@include file="/tp/web/iBusinessException.jsp"%>
<table width="700" border="0" align="center" cellpadding="4"
cellspacing="0">
<tr>
<td class="tdWscHeading">
<img
src="<%=request.getContextPath()%>/tp/web/console/include/images/iconCreateuser.gif"
alt="Task Summary" width="20" height="20" align="absmiddle">
<spring:message code='label.createuser'></spring:message>
</td>
</tr>
</table>
<table width="700" border="0" align="center" cellpadding="4"
cellspacing="1" class="tableWscmain">
<tr>
<td width="250" class="tdWscContent fontBold">
<spring:message code='label.firstname'></spring:message>
<span class="fontRed"> *</span>
</td>
<td class="tdWscContent">
<form:input path="firstname" cssClass="formINPUT"
autocomplete="off" />
<!-- Error Message if Key is Empty Starts -->
<span class="error"> <spring:bind path="firstname">
<c:if test="${not empty status.errorMessage}">
<c:out value="${status.errorMessage}" escapeXml="false" />
</c:if>
</spring:bind> </span>
<!-- Error Message if key is Empty Ends -->
</td>
</tr>
<tr>
<td class="tdWscContent fontBold">
<spring:message code='label.lastname'></spring:message>
<span class="fontRed"> *</span>
</td>
<td class="tdWscContent">
<form:input path="lastname" cssClass="formINPUT"
autocomplete="off" />
<!-- Error Message if Key is Empty Starts -->
<span class="error"> <spring:bind path="lastname">
<c:if test="${not empty status.errorMessage}">
<c:out value="${status.errorMessage}" escapeXml="false" />
</c:if>
</spring:bind> </span>
<!-- Error Message if key is Empty Ends -->
</td>
</tr>
<tr>
<td class="tdWscContent fontBold">
<spring:message code='label.username'></spring:message>
<span class="fontRed"> *</span>
</td>
<td class="tdWscContent">
<form:input path="username" cssClass="formINPUT"
autocomplete="off" />
<!-- Error Message if Key is Empty Starts -->
<span class="error"> <spring:bind path="username">
<c:if test="${not empty status.errorMessage}">
<c:out value="${status.errorMessage}" escapeXml="false" />
</c:if>
</spring:bind> </span>
<!-- Error Message if key is Empty Ends -->
</td>
</tr>
<tr>
<td class="tdWscContent fontBold">
<spring:message code='label.password'></spring:message>
<span class="fontRed"> *</span>
</td>
<td class="tdWscContent">
<form:password path="password" cssClass="formINPUT"
autocomplete="off" showPassword="false" />
<!-- Error Message if Key is Empty Starts -->
<span class="error"> <spring:bind path="password">
<c:if test="${not empty status.errorMessage}">
<c:out value="${status.errorMessage}" escapeXml="false" />
</c:if>
</spring:bind> </span>
<!-- Error Message if key is Empty Ends -->
</td>
</tr>
<tr>
<td class="tdWscContent fontBold">
<spring:message code='label.email'></spring:message>
<span class="fontRed"> *</span>
</td>
<td class="tdWscContent">
<form:input path="email" cssClass="formINPUT"
autocomplete="off" />
<!-- Error Message if Key is Empty Starts -->
<span class="error"> <spring:bind path="email">
<c:if test="${not empty status.errorMessage}">
<c:out value="${status.errorMessage}" escapeXml="false" />
</c:if>
</spring:bind> </span>
<!-- Error Message if key is Empty Ends -->
</td>
</tr>
<tr>
<td class="tdWscContent fontBold">
<spring:message code='label.groupname'></spring:message>
<span class="fontRed"> *</span>
</td>
<td class="tdWscContent">
<select id="groupname" name="groupname">
<c:forEach items="${GROUPS_LIST_RESULT}" var="option">
<option value='<c:out value="${option.groupname}" />'>
<c:out value="${option.groupname}" />
</option>
</c:forEach>
</select>
<!-- Error Message if Key is Empty Starts -->
<span class="error"> <form:errors path="groupname"></form:errors>
</span>
<!-- Error Message if key is Empty Ends -->
</td>
</tr>
<tr align="center">
<td colspan="2" class="tdWscContent fontBold">
<input type="submit" name=""
value="<spring:message code="label.createuser"></spring:message>">
</td>
</tr>
</table>
</form:form>
MyController
@RequestMapping(value = USERADMINISTRATION_NAMESPACE + "/createUser.do", method = RequestMethod.POST)
public ModelAndView submitCreateUserPage(
@ModelAttribute("userModel") User user, BindingResult result
) throws UserAlreadyExistsException {
String password = "";
password = user.getPassword();
/* Here , password i am getting like **¤** , */
/* I want exactly same Japanese characters as entered by user */
}
I have not use any character encoding filter in my application.
From jsp to controller , it is automatically converted into such above number.. I want exactly same Japanese characters as entered by user in jsp and want to insert same into DB and display on page.
I am passing all user input field's value from JSP to controller as a POJO.
Please help...