【发布时间】:2011-03-31 07:29:41
【问题描述】:
希望你能帮我解决一个问题: 我在 2.1.8.1 版本中使用带有 struts2-json-plugin 的 Struts2。 JQuery-UI 的版本是 1.8.9。整个 shebang 在 Tomcat 7.0.8 上运行。 我的问题是这样的:当我在搜索字段中输入特殊字符(例如名称“Müller”)时,我的 struts-action 的方法 setTerm(String term) 使用参数“müller”调用。所以,很明显,发生了一些编码错误。
我为自动完成定义了一个源 Struts-Action,它的 configuration-xml 看起来像这样:
<action name="SearchUsers" class="...">
<interceptor-ref name="..." />
<result type="json">
<param name="root">users</param>
<param name="noCache">true</param>
</result>
</action>
这是我在网页上配置自动完成的方式:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="jquery-ui/jquery-1.4.4.min.js"></script>
<link rel="stylesheet" type="text/css" href="jquery-ui/css/ui-lightness/jquery.ui.all.css" />
<script type="text/javascript" src="jquery-ui/jquery-ui-1.8.9.custom.min.js"></script>
<script type="text/javascript">
$("#nachname").autocomplete({
source : "SearchUsers.action",
dataType : "json",
minLength : 3
});
</script>
</head>
<body>...</body>
</html>
提前感谢您的帮助!
【问题讨论】:
标签: json struts2 jquery-ui-autocomplete