大家来帮忙看看我的代码错在哪里!!!~都快急死了
我在servlet中的doGet方法中是这样写的:
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws
ServletException,
IOException,
java.net.MalformedURLException {
response.setContentType( "text/html; charset=UTF-8 ");
PrintWriter out = response.getWriter();
Locale clocale = request.getLocale();
StringWriter resultStringWriter = new StringWriter();
try {
XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
processor.setStylesheetParam( "lpfile ", "clocale ");
String xml_doc = "file://WebRoot/zheng XML-3.15/languages/en.xml ";
String stylesheet = "file://WebRoot/zheng XML-3.15/languages/DeviceGroup.xsl ";
processor.process(new XSLTInputSource(xml_doc),
new XSLTInputSource(stylesheet), new XSLTResultTarget(
resultStringWriter));
out.write(resultStringWriter.toString());
} catch (
SAXException e) {
e.printStackTrace();
}
}
但是在发布的时候服务器提示了这样的错误:
java.lang.NoClassDefFoundError: org/apache/xml/serialize/BaseMarkupSerializer
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:164)
org.apache.xalan.xslt.XSLTEngineImpl. <init> (XSLTEngineImpl.java:360)
org.apache.xalan.xslt.XSLTProcessorFactory.getProcessor(XSLTProcessorFactory.java:79)
com.adv.servlet.TestServlet.doGet(TestServlet.java:65)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
这是怎么回事啊?我快急死了!!~~求各位JAVA高手们帮忙!!!~~~
------解决方案--------------------java.lang.
NoClassDefFoundError: org/apache/xml/serialize/BaseMarkupSerializer
导入包含这个类的jar包啊
------解决方案--------------------http://archive.apache.org/dist/xml/xerces-j/
在这里下载,找一个适合你项目的版本的zip包,下载后解压,把其中的jar文件添加到构建路径中,就是lib下
------解决方案--------------------系统提示的是找不到BaseMarkupSerializer.class文件。
------解决方案-------------------- 系统提示的是找不到org/apache/xml/serialize/BaseMarkupSerializer.class文件。
估计是楼主的程序包引的不对
------解决方案--------------------没有JAR包
------解决方案--------------------程序包引的不对