拉丁字符在发送到服务器时被错误解释

我的应用程序是多语言支持。有一些西班牙用户在文本框/文本区域中输入一些拉丁字符,例如 á、é、í、ó、ú、ü、ñ、¿、¡

我尝试添加页面编码

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

但是在发送到服务器并显示时仍然显示不正确。

例如。用户正在输入comunicación但在数据库中它存储为comunicación


ABOUTYOU
浏览 78回答 1
1回答

手掌心

这是编码问题。不知何故,编码被改变了。我添加了编码过滤器。它工作正常。<filter>&nbsp; &nbsp; <filter-name>encoding-filter</filter-name>&nbsp; &nbsp; <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>&nbsp; &nbsp; <init-param>&nbsp; &nbsp; &nbsp; &nbsp;<param-name>encoding</param-name>&nbsp; &nbsp; &nbsp; &nbsp;<param-value>UTF-8</param-value>&nbsp; &nbsp; </init-param>&nbsp; &nbsp; <init-param>&nbsp; &nbsp; &nbsp; &nbsp;<param-name>forceEncoding</param-name>&nbsp; &nbsp; &nbsp; &nbsp;<param-value>true</param-value>&nbsp; &nbsp; </init-param></filter><filter-mapping>&nbsp; &nbsp; &nbsp; &nbsp;<filter-name>encoding-filter</filter-name>&nbsp; &nbsp; &nbsp; &nbsp;<url-pattern>/*</url-pattern></filter-mapping>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java