Foro de elhacker.net

Programación => Java => Mensaje iniciado por: joelmanx en 14 Octubre 2010, 19:05 pm



Título: error al abrir URI
Publicado por: joelmanx en 14 Octubre 2010, 19:05 pm
parece que estoy errando en algo, estoy intentando abrir una url:

Código:
try {
       Desktop ds = Desktop.getDesktop();
ds.browse(new URI("http://localhost/cgi-bin/mapserv.exe?map=C:\data\wms\pruebaDeEtiquetados.map&mode=map&layers cantonesCercado4326.shp focos.shp"));
} catch (IOException e1) {
e1.printStackTrace();
} catch (URISyntaxException e1) {
e1.printStackTrace();
}

y me lanza un error:

Código:
java.net.URISyntaxException: Illegal character in query at index 43: http://localhost/cgi-bin/mapserv.exe?map=C:\data\wms\pruebaDeEtiquetados.map&mode=map&layers cantonesCercado4326.shp focos.shp
at java.net.URI$Parser.fail(URI.java:2809)
at java.net.URI$Parser.checkChars(URI.java:2982)
at java.net.URI$Parser.parseHierarchical(URI.java:3072)
at java.net.URI$Parser.parse(URI.java:3014)
at java.net.URI.<init>(URI.java:578)
at com.pronefa.sig.wms.WMSEditor$4.actionPerformed(WMSEditor.java:178)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6263)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6028)

.......

alguna sugerencia para solucionarlo?.



Título: Re: error al abrir URI
Publicado por: Leyer en 14 Octubre 2010, 19:58 pm
Te falto colocar \\ ademas de codificar el parámetro

Código
  1. ds.browse(new URI("http://localhost/cgi-bin/mapserv.exe?map=" +
  2. ""+URLEncoder.encode("C:\\data\\wms\\pruebaDeEtiquetados.map&mode=map&layers cantonesCercado4326.shp focos.shp",
  3. "UTF8" ) ) );

Un saludo.