|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Sep 2002
Città: Celano (AQ) Segno_Zodiacale: Leone Ascendente: Cammello Segni_Particolari: Quello
Messaggi: 9571
|
[JAVA] HTML Entities ENCODE!
Salve!
Ho bisogno di un metodo java che mi faccia l'encoding di tutti i caratteri che non siano lettere o numeri in html entities. Sto cercando da un po' ma ne ho trovata solo una che però ad esempio non mi converte le accentate in html entities. Sapete darmi una mano? Grazie! |
|
|
|
|
|
#2 | |
|
Senior Member
Iscritto dal: Oct 2007
Città: Padova
Messaggi: 4131
|
Quote:
__________________
As long as you are basically literate in programming, you should be able to express any logical relationship you understand. If you don’t understand a logical relationship, you can use the attempt to program it as a means to learn about it. (Chris Crawford) |
|
|
|
|
|
|
#3 |
|
Senior Member
Iscritto dal: Sep 2002
Città: Celano (AQ) Segno_Zodiacale: Leone Ascendente: Cammello Segni_Particolari: Quello
Messaggi: 9571
|
So che ci sono librerie esterne che fanno questo lavoro, come quella che hai citato. Ma non vorrei ricorrere ad una libreria esterna per una sola funzione che mi serve...
|
|
|
|
|
|
#4 | |
|
Senior Member
Iscritto dal: Oct 2007
Città: Padova
Messaggi: 4131
|
Quote:
In ogni caso, a questa pagina trovi un riferimento circa le Html Entities... Di primo acchitto direi che servirebbe una lista di mappe, una per ogni charset che si vuol supportare, dove la chiave è un simbolo dell'alfabeto di quel charset, e il valore è la Html Entity corrispondente (nella sua forma mnemonica "&..." piuttosto che in quella numerica "&#..."). Non so se è conveniente fare tutto sto lavoro "a mano", quando esiste la "pappa pronta". Usare librerie serve apposta per non reinventare la ruota, e concentrare sforzi e tempo su quello che è il nostro vero obiettivo. Se poi il tuo è implementare questa conversione, allora buon lavoro.
__________________
As long as you are basically literate in programming, you should be able to express any logical relationship you understand. If you don’t understand a logical relationship, you can use the attempt to program it as a means to learn about it. (Chris Crawford) |
|
|
|
|
|
|
#5 |
|
Senior Member
Iscritto dal: Sep 2002
Città: Celano (AQ) Segno_Zodiacale: Leone Ascendente: Cammello Segni_Particolari: Quello
Messaggi: 9571
|
Ho optato per l'utilizzo della libreria Apache Commons Lang!
Ora però ho un problema... Codice:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 6 in the generated java file
Only a type can be imported. org.apache.commons.lang.StringEscapeUtils resolves to a package
An error occurred at line: 43 in the jsp file: /editor.jsp
StringEscapeUtils cannot be resolved
40: sNome = oDocRs.getString("nome");
41: sDescrizione = oDocRs.getString("descrizione");
42: sTipo = oDocRs.getString("tipo");
43: sContenuto = StringEscapeUtils.unescapeHtml(oDocRs.getString("contenuto"));
44: sDataCreazione = oDocRs.getString("create_date");
45: sDataModifica = oDocRs.getString("modified_date");
46: }
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:326)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
<%@page import="org.apache.commons.lang.StringEscapeUtils"%> e ho importato il jar nella folder Libraries del progetto in NetBeans... Come mai fa così? |
|
|
|
|
|
#6 |
|
Senior Member
Iscritto dal: Oct 2007
Città: Padova
Messaggi: 4131
|
Boh
Non so praticamente niente circa le tecnologie orientate allo sviluppo per il web, quindi io non ti so aiutare, in questo caso...
__________________
As long as you are basically literate in programming, you should be able to express any logical relationship you understand. If you don’t understand a logical relationship, you can use the attempt to program it as a means to learn about it. (Chris Crawford) |
|
|
|
|
|
#7 |
|
Senior Member
Iscritto dal: Oct 2007
Città: Padova
Messaggi: 4131
|
Edit: prova importanto tutte le classi del package "org.apache.commons.lang", così
Codice:
<%@ page import="org.apache.commons.lang.*" %>
__________________
As long as you are basically literate in programming, you should be able to express any logical relationship you understand. If you don’t understand a logical relationship, you can use the attempt to program it as a means to learn about it. (Chris Crawford) Ultima modifica di banryu79 : 14-04-2011 alle 12:56. |
|
|
|
|
|
#8 |
|
Senior Member
Iscritto dal: Sep 2002
Città: Celano (AQ) Segno_Zodiacale: Leone Ascendente: Cammello Segni_Particolari: Quello
Messaggi: 9571
|
aggiornamento: ora funziona. non so perchè, forse è bastato un clean & build o un riavvio dell'ambiente di sviluppo... cmq va bè tutto è bene quello che finisce bene!
|
|
|
|
|
|
#9 | |
|
Senior Member
Iscritto dal: Oct 2007
Città: Padova
Messaggi: 4131
|
Quote:
http://plugins.netbeans.org/plugin/2...-sonderzeichen
__________________
As long as you are basically literate in programming, you should be able to express any logical relationship you understand. If you don’t understand a logical relationship, you can use the attempt to program it as a means to learn about it. (Chris Crawford) |
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 16:46.



















