【发布时间】:2014-06-26 11:50:41
【问题描述】:
我的jsp页面编码如下:
<%@ page
contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"
%>
<%
response.setHeader("Cache-control", "no-cache");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", 0);
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
%>
javascript代码在firebug中很好地打印希腊字符以下是代码:
function save() {
console.log(document.editDistributionListForm.elements['name'].value); //this line prints greek characters
document.editDistributionListForm.elements['subAction'].value='submit';
document.editDistributionListForm.submit();
}
当上面的'name'值被发送到struts动作时,字符串不打印希腊字符而是打印????????????????
输入的希腊字符是:αβγδεζηθ
Struts Bean(示例代码):
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
Struts Action(示例代码):
protected ActionForward updateList(ActionMapping mapping,
HttpServletRequest request,
EditListForm form)
throws CannotOverwriteExistingListException, EmptyListException,
ListUpdateException {
log.debug("form.getName :: "+form.getName()); //this line when printed prints (???)
}
当数据从 html 发送到 java,即从浏览器发送到服务器时,字符串会从希腊语转换为 ????我做错了什么。我无法确定我错过了什么.. .
请帮忙。
【问题讨论】:
-
你在使用 Eclipse 吗?看看这里stackoverflow.com/questions/7539590/…
-
不,我没有使用 Eclipse ..
-
“utf8 字符”不是一个东西。
标签: java javascript jsp utf-8 struts-1