Java + XML Chinese Problem Solution

xiaoxiao2021-03-05  22

Import javax.xml.transform.transformerfactory;

Import javax.xml.transform. *;

Import javax.xml.transform.Stream.streamsource;

Import javax.xml.transform.Stream.streamResult;

Import javax.xml.transform.transformerexception;

Import javax.xml.transform.transformerConfigurationException;

Import java.io.fileoutputstream;

Import java.io.filenotfoundexception;

Import java.io.ioException;

Import java.io. *;

Import javax.servlet. *;

Import javax.servlet.http. *;

Import javax.servlet.http.httpservlet;

/ **

* Title: Test

* Description: Case Study

* Copyright: CopyRight (C) 2001

* Company:

* @Author tony chen

* @version 1.0

* /

Public class test extends httpservlet {

Private static final string content_type = "text / html";

/ ** Initialize Global Variables * /

Public void init (servletconfig config) throws servletexception {

Super.init (config);

}

/ ** Process the http get request * /

Public void doget (httpservletRequest request, httpservletResponse response) throws servletexception, ioException {

Try {

TransformerFactory Tfactory = TransformerFactory.newInstance ();

TRANSFORMER TRANSFORMER =

TFactory.NewTransformer (New File ("C: /Resin/jworkflow/xsl/xxx.xsl"))));

Transformer.setputProperty ("Encoding", "GB2312");

Transformer.Transform

New streamsource (New File ("C: /Resin/jworkflow/web-inf/classes/xml/yyy.xml"),

New streamResult (response.getoutputstream ());

}

Catch (Exception E) {E.PrintStackTrace ();

}

/ ** Clean Up Resources * /

Public void destroy () {

}

}

转载请注明原文地址:https://www.9cbs.com/read-39366.html

New Post(0)