我使用cb.SetTextMatrix(document.LeftMargin, document.PageSize.Height - document.TopMargin);
来回复临时文件。在将此文件写入响应流后,如何删除该文件?
底层服务器是spray-servlet。
答案 0 :(得分:0)
最后我找到了解决方案:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:component-scan base-package="mypack" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" />
</beans>
然后使用case class CleanupFile(file: java.io.File)
def sendFileAndCleanup(file: java.io.File) =
mapRequestContext { ctx =>
ctx.withRouteResponseMapped {
case r: spray.http.HttpResponse => r.withAck(CleanupFile(file))
case x => x
}
} {
getFromFile(file)
}
:
CleanupFile
runRoute