简体   繁体   English

从CSV文件打印HTML实体

[英]Print HTML entities from CSV file

Using JSP on a Tomcat I need to load a CSV file and then create an XML output for it to show be shown in the screen. 在Tomcat上使用JSP,我需要加载一个CSV文件,然后为其创建XML输出以显示在屏幕上。 My problem is that sometime this CSV file has special characters like ç, á, é, ó, etc. And in the Web Output (screen) I need to print the ISO-8859-1 entities equivalency, say, instead of ç I need to show ç 我的问题是,有时此CSV文件具有特殊字符,例如ç,á,é,ó等。在Web输出(屏幕)中,我需要打印ISO-8859-1实体的等效性,例如,而不是ç显示ç

So word açucar needs to be shown as: açucar 因此,单词açucar必须显示为:aç ucar

I can read the CSV file but can't figure out how to tell JSP to print those html entities as I need to. 我可以读取CSV文件,但无法弄清楚如何告诉JSP根据需要打印这些html实体。

So if CSV file is: 因此,如果CSV文件为:

product;quantity;value 产物;数量;值

açucar;5723;7.00; Açucar山; 5723; 7.00;

I need to print in my screen something like: 我需要在屏幕上打印以下内容:

 <item> <product>a&amp;#xe7;ucar</product> <quantity>5723</quantity> <value>7.00</value> </item> 

Any idea how to do this? 任何想法如何做到这一点?

Why can't you just use UTF-8 or something like that? 您为什么不能只使用UTF-8或类似的东西? Surely any web browser should accept it. 当然,任何网络浏览器都应该接受它。

Otherwise, you might want to have a look at this: Recommended method for escaping HTML in Java 否则,您可能需要看一下: 在Java中转义HTML的推荐方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM