【发布时间】:2015-02-05 10:57:21
【问题描述】:
我有一个非常简单的 html,带有一个提交按钮和一个文本框,可将 unicode(波斯语)文本发送到 servlet 并在 weblogic 上运行。我在 jsp 页面中设置了 charset=UTF-8 和 request.setCharacterEncoding("UTF-8");在servlet中,但是当我从请求中获取参数并将其打印或将其插入数据库时,它是??? 我也使用 URLDecoder,但它没有帮助。我该如何解决这个问题? html代码:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
</head>
<body>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<fmt:requestEncoding value="UTF-8" />
<form method="get" action="main">
<input type="submit" name="search" value="جستجو" >
<input type="text" name="keyWord" class="bodyfont" >
</form>
</body>
</html>
servlet 代码:
request.setCharacterEncoding("UTF-8");
String input = URLDecoder.decode(request.getParameter("keyWord"), "UTF-8");
System.out.println(input);
System.out.println(request.getParameter("keyWord"));
【问题讨论】:
标签: java jsp servlets unicode utf-8