English 中文(简体)
我怎么能处理我保存的“UTF-8”号编码座标。
原标题:How can I handle UTF-8 encoded strings in my servlet

After searching for 4 straight hours now, I have to give up and ask you guys. I have a very simple form which will take an input and on action, write it to my Oracle DB (which supports UTF-8).

<form action="test.jsp" method= GET  accept-charset="UTF-8">
    <label for= NAME >Name</label><input type="text" id="NAME" name="NAME"/>
    <button type="submit">Submit</button> 
 </form>

All I want to do is the form to be able to accept characters such as é or and store them without changing the encoding.

我已经尝试过(合并)办法,例如制定办法。

request.setCharacterEncoding("UTF-8”;

或建造带有编码参数的新力量:

new String(request.getPara amount("NAME”).getBytes(),“UTF-8”

但它总是在数据库中结束,如:??>>>/code>)

在这个问题上的任何帮助都将受到高度赞赏。

最佳回答

In Tomcat server.xml, add a URIEncoding="UTF-8" attribute to your Connector like so:

<Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" URIEncoding="UTF-8"/>

rel=“nofollow noreferer”> 国家:

This specifies the character encoding used to decode the URI bytes, after %xx decoding the URL. If not specified, ISO-8859-1 will be used.

可查阅

问题回答

你们是否看清了在java插入数据库之前如何看看? 如果没有混杂,数据库的进口功能就是这样。 你们在那里使用哪种疗法或用途?





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签