You are absolutely right Matt. Thanks! :)
I have added 'default-character-set=utf8' to my [mysqld] section in
/etc/mysql/my.cnf file then dropped the database and recreated it and it
works like a charm.
I have another problem: in my real application I try to add a user with
Polish characters.
My controller looks like that:
@RequestMapping(value="/userform.*", method=RequestMethod.POST)
public ModelAndView processSubmit(@ModelAttribute("user") User user,
BindingResult result, SessionStatus status,
HttpServletRequest request) {
log.debug(request.getCharacterEncoding());
log.debug(user);
if (request.getParameter("delete") != null) {
userManager.removeUser(user);
request.getSession().setAttribute("message",
getText("user.deleted", user.getFullName()));
} else {
userManager.saveUser(user);
request.getSession().setAttribute("message",
getText("user.saved", user.getFullName()));
}
return new ModelAndView(getSuccessView());
}
and the controller log says:
DEBUG - UserFormController.processSubmit(55) | UTF-8
DEBUG - UserFormController.processSubmit(56) |
[EMAIL PROTECTED]
jaźÅ,password=h,firstName=gÄÅlÄ
,lastName=jaźÅ,id=<null>]
DEBUG - UserManagerImpl.saveUser(33) | gÄÅlÄ
So the characters are corrupted before adding to the database. The problem
is weird because my application is based on the original appfuse-light
framework. I have only added some fields to my User class. I've checked also
my web.xml file and it contains a proper filter:
...
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
...
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
My user form jsp looks like this (for now I've turned off the validation):
<%@ include file="/WEB-INF/pages/taglibs.jsp" %>
<head>
<title><fmt:message key="userForm.title"/></title>
</head>
<p id="info"> </p>
<form:form commandName="user" method="post" id="userForm" name="userForm">
<form:errors path="*" cssClass="error"/>
<table class="detail">
<tr>
<th><label for="login"><fmt:message
key="label.user.login"/>:</label></th>
<td>
<form:input path="login" id="login"/>
<form:errors path="login" cssClass="fieldError"/>
</td>
</tr>
<tr>
<th><label for="firstName"><fmt:message
key="label.user.first-name"/>:</label></th>
<td>
<form:input path="firstName" id="firstName"/>
<form:errors path="firstName" cssClass="fieldError"/>
</td>
</tr>
<tr>
<th><label for="lastName" class="required"><fmt:message
key="label.user.last-name"/>:</label></th>
<td>
<form:input path="lastName" id="lastName"/>
<form:errors path="lastName" cssClass="fieldError"/>
</td>
</tr>
<tr>
<th><label for="password"><fmt:message
key="label.user.password"/>:</label></th>
<td>
<form:password path="password" id="password" showPassword="true"/>
<form:errors path="password" cssClass="fieldError"/>
</td>
</tr>
<tr>
<th><label for="confirmPassword"><fmt:message
key="label.user.confirm-password"/>:</label></th>
<td>
<form:password path="confirmPassword" id="confirmPassword"
showPassword="true"/>
<form:errors path="confirmPassword" cssClass="fieldError"/>
</td>
</tr>
<tr>
<th><label for="enabled"><fmt:message
key="label.user.enabled"/>:</label></th>
<td>
<form:checkbox path="enabled" id="enabled"/>
<form:errors path="enabled" cssClass="fieldError"/>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="save" value="<fmt:message
key="button.save"/>" />
<input type="submit" name="delete" value="<fmt:message
key="button.delete"/>" onclick="javascript:document.userForm.submit();"/>
<input type="button" name="cancel" value="<fmt:message
key="button.cancel"/>"
onclick="javascript:window.location='${ctx}/users.html'"/>
</td>
</tr>
</table>
</form:form>
I have no idea what does this problem come from... :/
Regards,
Pawel
mraible wrote:
>
> You might try recreating your database and making sure you use UTF-8.
>
> http://raibledesigns.com/wiki/Wiki.jsp?page=AppFuseSupport#ref-AppFuseSupport-6
>
> Matt
>
--
View this message in context:
http://www.nabble.com/Adding-a-user-in-UTF-8-in-appfuse-light-tp20681790s2369p20698464.html
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]