0

我在 Eclipse 中使用 JSP 和 Spring MVC 开发了一个 Web 应用程序。当我在 Eclipse 中运行应用程序时运行良好,但是当我在 tomcat 7 中加载 war 文件时,当应用程序必须打印票时它不会,并且不会引发错误。下一个日志来自本地主机访问

> 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&param2=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 9581

Catalina log it ok without errors 下一部分是 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();
        }
    }
} 
4

1 回答 1

0

我发现问题是要打印的文件的路径,当我的应用程序在warfile的路径中打印时,tomcat会在文件夹的根目录中创建文件

于 2012-07-23T22:15:44.380 回答