jjh 1 year ago
commit 658fcebaba

@ -1,11 +1,13 @@
package cokr.xit.fims.base; package cokr.xit.fims.base;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.StringWriter; import java.io.StringWriter;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.regex.Matcher;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -78,14 +80,16 @@ public class FileController extends cokr.xit.base.file.web.FileController {
String requestURI = request.getRequestURI().toString(); String requestURI = request.getRequestURI().toString();
String filepath = requestURI.split("modifySvg")[1]; String filepath = requestURI.split("modifySvg")[1];
filepath = URLDecoder.decode(filepath); filepath = URLDecoder.decode(filepath, "UTF-8");
filepath = filepath.replace("\\","/"); filepath = filepath.replaceAll("/", Matcher.quoteReplacement(File.separator));
String svgRootPath = ("classpath:svg"); filepath = "svg" + filepath;
filepath = svgRootPath + filepath;
ClassPathResource resource = new ClassPathResource(filepath);
InputStream is = resource.getInputStream();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = factory.newDocumentBuilder(); DocumentBuilder documentBuilder = factory.newDocumentBuilder();
Document document = documentBuilder.parse(filepath); Document document = documentBuilder.parse(is);
Element root = document.getDocumentElement(); Element root = document.getDocumentElement();
NodeList nodeList = root.getChildNodes(); NodeList nodeList = root.getChildNodes();

Loading…
Cancel
Save