---
title: "Struts2在使用Freemarker时,在Action中乱码"
author: "dcriori"
date: "2009-12-21T14:07:31Z"
tags: []
categories: ["企业架构"]
slug: "struts2-freemarker-action"
draft: false
lastmod: "2009-12-21T14:08:06Z"
id: 552796
url: "https://dcriori.iteye.com/blog/552796"
---

所有配置的地方都使用了UTF-8，但是在struts 的 action 的 result type为 freemarker的时候，在action中得到的还是乱码。后来想到可能是tomcat配置的问题，tomcat的默认字符集是iso8859-1,导致乱码，于是设置tomcat下conf下server.xml文件中的图片部分，在后面加上URIEncoding="UTF-8"。这样再使用UTF-8国际字符集基本不会出现乱码问题。记录一下。

![](http://dl.iteye.com/upload/attachment/183266/ea1b6dfc-8314-3083-9d62-10e58e6ea53a.jpg)