JSF UTF 8 characters not seen ONLY in first form post, jsf, tomcat? -
i have simple jsf form submit username , password , persist database.
only in first form submit, having problems utf-8 characters. when submit ğğüüçç in first post, wrong characters. in second try, alright.
here web.xml , index.xhtml:
<?xml version="1.0" encoding="utf-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <servlet> <servlet-name>faces servlet</servlet-name> <servlet-class>javax.faces.webapp.facesservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>faces servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>faces servlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.xhtml</welcome-file> </welcome-file-list> </web-app>
and index.xhtml :
<!doctype html> <html lang="tr" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"> <h:head> <title>title</title> </h:head> <h:body> <div class="container"> <h:form styleclass="form-signin" prependid="false" id="registirationform"> <h2 class="form-signin-heading">please register!</h2> <h:inputtext styleclass="input-block-level" value="#{registirationformbean.nickname}" /> <h:inputsecret styleclass="input-block-level" value="#{registirationformbean.password}"/> <h:commandbutton styleclass="btn btn-large btn-primary" value="register me!" action="#{registirationformbean.registeruser}"/> </h:form> </div> </h:body> </html>
edit: server.xml in tomcat
<connector port="8080" maxhttpheadersize="8192" maxthreads="150" minsparethreads="25" maxsparethreads="75" enablelookups="false" redirectport="8443" acceptcount="100" connectiontimeout="20000" disableuploadtimeout="true" uriencoding="utf-8" />
when debug application, in first post see values posted:
but in second time:
use
<f:view>
and locale.
<f:view locale="#{registirationformbean.locale}" encoding="utf-8" contenttype="text/html"> <h:head> <title>title</title> </h:head> <h:body> <div class="container"> <h:form styleclass="form-signin" prependid="false" id="registirationform"> <h2 class="form-signin-heading">please register!</h2> <h:inputtext styleclass="input-block-level" value="#{registirationformbean.nickname}" /> <h:inputsecret styleclass="input-block-level" value="#{registirationformbean.password}"/> <h:commandbutton styleclass="btn btn-large btn-primary" value="register me!" action="#{registirationformbean.registeruser}"/> </h:form> </div> </h:body> </f:view>
provide locale object bean .
public locale getlocale(){ return new locale("tr", "tr"); }
Comments
Post a Comment