泽西 2 注入源的多部分表单数据
2022-09-01 11:21:37
我有一个方法:
@POST
@Consumes("multipart/form-data")
@Produces( {"text/xml"})
public Response processForm(
@FormDataParam("myparam") InputStream is,
@FormDataParam("myparam") FormDataContentDisposition detail)
这与泽西岛1.x一起工作得很好。
我正在升级到 2.0 m11。
现在我得到以下错误:
12/01/2013 11:15:04 AM org.glassfish.jersey.server.ApplicationHandler initialize
INFO: Initiating Jersey application, version Jersey: 2.0-m11 2012-12-21 12:34:15...
12/01/2013 11:15:04 AM org.glassfish.jersey.internal.Errors processErrors
SEVERE: The following errors and warnings have been detected:
WARNING: No injection source found for a parameter of type public javax.ws.rs.core.Response com.plutext.FileUpload.processForm(java.io.InputStream,org.glassfish
.jersey.media.multipart.FormDataContentDisposition) at index 0.
我发现 http://java.net/jira/browse/JERSEY-1413 并提交 http://java.net/projects/jersey/lists/commits/archive/2012-09/message/126 这似乎很重要,但对我来说,如何解决问题并不明显。
更新
我做了一个servlet,它在org.glassfish.jersey.server.ApplicationHandler初始化之前在Tomcat中运行:
public class Jersey2Init extends HttpServlet {
private static final Logger jul = Logger.getLogger(Jersey2Init.class
.getName());
static {
System.out.println("\n\nrunning Jersey2Init\n\n");
final ResourceConfig resourceConfig1 = new ResourceConfig(XFormService.class);
resourceConfig1.registerInstances(new LoggingFilter(jul, true));
resourceConfig1.register(MultiPartFeature.class);
final ResourceConfig resourceConfig2 = new ResourceConfig(AssembleService.class);
resourceConfig2.registerInstances(new LoggingFilter(jul, true));
resourceConfig2.register(MultiPartFeature.class);
}
}
它肯定是首先运行的:
INFO: Deploying web application archive C:\Java\apache-tomcat-7.0.29\webapps\Foo-Services.war
running Jersey2Init
18/01/2013 9:09:51 PM org.glassfish.jersey.server.ApplicationHandler initialize
INFO: Initiating Jersey application, version Jersey: 2.0-m11 2012-12-21 12:34:15...
18/01/2013 9:09:52 PM org.glassfish.jersey.internal.Errors processErrors
SEVERE: The following errors and warnings have been detected:
但我仍然得到同样的错误。