当我添加此代码时,我的整个休息服务停止工作:
@PUT
@Path("upload/{id}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void addBlob(@PathParam("id") Integer id, @FormDataParam("file") InputStream uploadedInputStream) throws IOException {
TheTempClient entityToMerge = find(id);
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
int read = 0;
byte[] bytes = new byte[1024];
while ((read = uploadedInputStream.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
entityToMerge.setTestBlob(out.toByteArray());
super.edit(entityToMerge);
}
catch (IOException e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
它没有真正说明为什么,我得到的只是:
Severe: WebModule[/MavenProjectTest]StandardWrapper.Throwable
org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
Run Code Online (Sandbox Code Playgroud)
还有一堆错误说" 由以前的错误引起的 "
我一定在这里做了一些非常错误的事,有没有专业的JPA爱好者可以在这里帮助我一点点?
编辑:我正在使用注释而不是web.xml,是否可以在没有web.xml的情况下执行此操作?
我必须添加register(MultiPartFeature.class);
在ApplicationConfig.java
课堂上,像这样:
@javax.ws.rs.ApplicationPath("api")
public class ApplicationConfig extends ResourceConfig {
public ApplicationConfig() {
packages("com.test.thepackage.service");
register(MultiPartFeature.class);
}
Run Code Online (Sandbox Code Playgroud)
}
现在它就像一个魅力,无需 web.xml 文件。
归档时间: |
|
查看次数: |
140 次 |
最近记录: |