我在eclipse中使用JSP和Spring MVC开发了一个web应用程序。当我在eclipse中运行应用程序时,它工作得很好,但是当我在tomcat7中加载war文件时,当应用程序必须打印票证时,它不会这样做,也不会抛出错误。下一个日志来自localhost访问
> 127.0.0.1 - - [23/Jul/2012:11:41:29 -0600] "GET /LilyStore/ HTTP/1.1" 200 2866
> 127.0.0.1 - - [23/Jul/2012:11:41:29 -0600] "GET /LilyStore/Css//LiliStyle.css HTTP/1.1" 304 -
> 127.0.0.1 - - [23/Jul/2012:11:41:29 -0600] "GET /LilyStore/JS//funciones.js HTTP/1.1" 304 -
> 127.0.0.1 - - [23/Jul/2012:11:41:33 -0600] "POST /LilyStore/forms/validateLogin.html?parametro=jav¶m2=123 HTTP/1.1"
> 200 6606
> 127.0.0.1 - - [23/Jul/2012:11:41:33 -0600] "GET /LilyStore//Css//LiliStyle.css HTTP/1.1" 304 -
> 127.0.0.1 - - [23/Jul/2012:11:41:33 -0600] "GET /LilyStore//JS//funciones.js HTTP/1.1" 304 -
> 127.0.0.1 - - [23/Jul/2012:11:41:38 -0600] "GET /LilyStore/forms/showVentasPorRango HTTP/1.1" 200 9581
> 127.0.0.1 - - [23/Jul/2012:11:41:38 -0600] "GET /LilyStore//JS//calendar_eu.js HTTP/1.1" 304 -
> 127.0.0.1 - - [23/Jul/2012:11:41:39 -0600] "GET /LilyStore/forms/makeCorte.html HTTP/1.1" 200 9581Catalina日志没有错误。下一部分是catalina log.jul的最后几行。
23, 2012 11:41:10 AM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/showVentasPorRangoMostrar.*] onto handler 'ventasControllerImpl'
jul 23, 2012 11:41:10 AM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/showVentasPorRangoMostrar/] onto handler 'ventasControllerImpl'
jul 23, 2012 11:41:10 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'dispatcher': initialization completed in 5980 ms
jul 23, 2012 11:41:10 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\docs
jul 23, 2012 11:41:10 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\manager
jul 23, 2012 11:41:10 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT
jul 23, 2012 11:41:10 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
jul 23, 2012 11:41:10 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
jul 23, 2012 11:41:10 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 9738 ms
jul 23, 2012 11:52:47 AM org.apache.jasper.compiler.TldLocationsCache tldScanJar
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.在程序中,会创建一个文件来打印它。打印该文件的方法如下:
public void imprimir(String ticketName){
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
//use the default printer
PrintService service = PrintServiceLookup.lookupDefaultPrintService();
if (service != null) {
try {
//create a print job
DocPrintJob job = service.createPrintJob();
//attributes of the job
DocAttributeSet das = new HashDocAttributeSet();
FileInputStream fis = new FileInputStream(ticket+".txt");
Doc doc = new SimpleDoc(fis,flavor,das);
try {
//the job is send it to the printer
job.print(doc,null);
}
catch(Exception e){
e.printStackTrace();
}
}
catch(Exception e){
e.printStackTrace();
}
}
} 发布于 2012-07-24 06:15:44
我发现问题出在要打印的文件的路径上,当我的应用程序在warfile的路径下打印时,tomcat会在文件夹的根目录下创建该文件
https://stackoverflow.com/questions/11595543
复制相似问题