mapxtreme java新建web项目下servlet问题
我在这个MayServlet.java内写下:import java.awt.Color;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mapinfo.mapj.MapJ;
import com.mapinfo.mapxtreme.client.MapXtremeImageRenderer;
import com.mapinfo.util.*;
import com.mapinfo.xmlprot.mxtj.ImageRequestComposer;
//import com.myservlets.DoubleRect;
//import com.mapinfo.unit.LinearUnit
import com.mapinfo.dp.*;
import com.mapinfo.dp.util.*;
import com.mapinfo.graphics.*;
import com.mapinfo.mapj.Layer;
import com.mapinfo.mapj.Layers;
import com.mapinfo.mapxtreme.client.MapXtremeDataProviderRef;
import com.mapinfo.mapdefcontainer.MapDefContainer;
public class MyServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public MyServlet() {
super();
}
//输出图片的格式
private static String mimeType = "image/gif";
//定义mdf文件的位置
private static String m_mapPath =
"E: \\MapXtremeJava471\\MapXtreme-4.7.1\\examples\\server\\data\\PCOS-02220523\\guizhou.mdf";
//定义mapxtreme servlet的URL
private static String m_mxtURL
=" http://localhost:8080/mapxtreme471/servlet/mapxtreme";
//实现httpService的doget()方法
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//设置contentType的类型
response.setContentType(mimeType);
//设置返回响应的输出流
ServletOutputStream sos = response.getOutputStream();
//创建mapJ对象
MapJ m_mapj = new MapJ();
//加载地图
m_mapj.loadMapDefinition(m_mapPath);
//设置地图大小
m_mapj.setDeviceBounds(new DoubleRect(0,0,800,600));
try {
//设置图像请求器(包装mapJ、图片的色位、底色、contentType类型)
ImageRequestComposer irc =
ImageRequestComposer.create(m_mapj,ImageRequestComposer.MAX_COLORS_TRUECOLOR,Color.white,mimeType);
//创建图片渲染器
MapXtremeImageRenderer renderer = new MapXtremeImageRenderer(m_mxtURL);
//用渲染器渲染请求器
renderer.render(irc);
//渲染器输出图片流到输出流,客户端显示之
renderer.toStream(sos);
//释放渲染器
renderer.dispose();
//刷新输出流
sos.flush();
//关闭输出流
sos.close();
}
catch (Exception e){
System.out.println("Error");
e.printStackTrace();
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doGet(request, response);
}
}
出现错误::::
java.lang.ClassNotFoundException: com.mapinfo.mapj.MapJ
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at com.servlets.MapServlet.doGet(MapServlet.java:38)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
包已经都易做图去了,有时候建同样的项目好的,有时候就这样出错,哎
--------------------编程问答-------------------- 楼主现在解决了吧,可以交流会吗?
补充:企业软件 , 地理信息系统