Mapxtreme java IntraServletContainerRenderer实现

IntraServletContainerRenderer是Mapxtreme java的一种渲染器,他的特点是,图片直接发送到客户机,不需要通过中间层,可以提高图片显示的速度,下面是他的具体实现

MapJ mapJ = new MapJ(); mapJ.loadMapDefinition("c:\\test.mdf"); mapJ.setDeviceBounds(new DoubleRect(0,0,800d,600d)); ServletConfig thisServletConfig = this.getServletConfig(); ServletContext thisServletContext = thisServletConfig.getServletContext(); this.logger.info("thisServletContext = " + thisServletContext.getContextPath()); //这个路径的是这样,你的项目的mapxtreme的路径是 //http://localhost:9090/test/mapxtreme //那么这里就写/test/mapxtreme就可以取到了 ServletContext mxtServletContext = thisServletContext.getContext("/test/mapxtreme"); this.logger.info("mxtServletContext = " + mxtServletContext); if(mxtServletContext != null) { try { IntraServletContainerRenderer isRenderer = new IntraServletContainerRenderer(mxtServletContext, "mapxtreme", request, response); ImageRequestComposer imageRC = ImageRequestComposer.create(mapJ, 256, Color.blue, "image/gif"); isRenderer.render(imageRC); } catch(Exception e) { } }

然后,还需要在web.xml里面还需要这么写

mapxtreme com.mapinfo.mapxtreme.MapXtremeServlet 1 mxtj_image com.mapinfo.mapxtreme.ImageHandlerServlet 2 mxtj_metadata com.mapinfo.mapxtreme.MetadataHandlerServlet 3 mxtj_vector com.mapinfo.mapxtreme.VectorHandlerServlet 4 namedresource com.mapinfo.jndi.namedres.NamedResourceServlet coordtransform com.mapinfo.coordsys.io.CoordTransformServlet mapxtreme /servlet/mapxtreme mapxtreme /mapxtreme namedresource /servlet/namedresource namedresource /namedresource coordtransform /servlet/coordtransform coordtransform /coordtransform

你可能感兴趣的:(Java,Servlet,Web,XML)