从JSP到PortletRequest的UTF-8编码

时间:2017-11-08 06:53:09

标签: encoding utf-8

 In the input field of the jsp page we are giving some value with special characters Arągł but those are not coming as given in the form. The value of the String query should be same as given but it's some thing like ArÄgÅ

服务器端代码:

     public void sendForm(PortletRequest request, Model model) throws UnsupportedEncodingException {   
             Map<String, String[]> renderParams = request.getParameterMap();
             for (Entry<String, String[]> entry : renderParams.entrySet()) {
                final String key = entry.getKey();
              final String[] c = entry.getValue();
                if (c != null && c.length > 0) {
                   if(key.contains("query")) {
                        String query = c[0];
                   }
                }
           }
        }

JSP代码:

<%@ taglib prefix="portlet" uri="http://java.sun.com/portlet_2_0" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <portlet:defineObjects />

    <portlet:actionURL var="formUrl" name="sendForm"/>

    <form name="editForm" 
          method="POST"
          action="${formUrl}"
          >
    <input type="text" name="query" id="query"/> 
        <input value="Submit" type="submit" />
    </form>

在jsp页面的输入字段中,我们给出了一些带有特殊字符Arągł的值,但这些值并没有像表格中给出的那样。 String查询的值应该与给定的相同,但它有点像ArÄgÅ

0 个答案:

没有答案