Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Problem with i18n:jsp,struts,utf-8

  Asked By: Phil    Date: Jun 18    Category: Java    Views: 1342
  

I have a problem with i18n in my project(for persian/farsi language l10n).
I get "?" marks instead of UTF-8 characters in browser.
APIs and tools which I use are:jsp,tiles,struts
,struts message resourses,native2ascii,UTF-8 and also I use windows XP.

in a nutshell I`ve used one seprate ApplicationPropeties_fa for farsi
Locale,
also I`ve changed locale to farsi but while compling the
ApplicationResource_fa,it convert to?.
any assitance would be appriciated in advance.

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Rosalie Holmes     Answered On: Jun 18

You need to define a farsi  filter for this to work.
Your filter should be like this
public class CharsetFilter implements Filter{

/**

* Logging output for this plug in instance.

*/

//private Log myLog = LogFactory.getLog(Constants.PACKAGE);

public void init(FilterConfig config) throws ServletException

{

//myLog.info(this.getClass().getName() + ": Starting filter.");

}

public void destroy()

{

//myLog.info(this.getClass().getName() + ": Destroying filter.");

}

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)

throws IOException, ServletException

{

request.setCharacterEncoding("UTF-8");

//myLog.info(this.getClass().getName() + ": Setting request to " +

// request.getCharacterEncoding());

chain.doFilter(request,response);

}

}

You also need to define your filter in web.xml such as this:
<filter>

<filter-name>FarsiFilter</filter-name>

<filter-class>com.project.filter.CharsetFilter</filter-class>

</filter>

<filter-mapping>

<filter-name>FarsiFilter</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>

 
Answer #2    Answered By: Zachary Larson     Answered On: Jun 18

Please see this link :

http://www.chinajsp.net/tech/struts/i18n,1.htm

Just consider codes,I hope it will be useful

 
Answer #3    Answered By: Ali Shahriari Garaei     Answered On: May 20

I had almost the same problem but i use Spring. I have solved it as here below:

put in your xml :


<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages"></property>
<property name="defaultEncoding" value="UTF-8"></property>
</bean>



 
Didn't find what you were looking for? Find more on Problem with i18n:jsp,struts,utf-8 Or get search suggestion and latest updates.




Tagged: