I have a multi-page form that should load a file, as well as some parameters. It looks like this:
<form id="upload" action="http://localhost:9998/test" method="post" enctype="multipart/form-data"> <input name="inputfile" type="file" size="50" accept="application/octet-stream"> <input name="someparameter" type="text" size="10"> <input type="submit" value="Go!"> </form>
The web service is as follows:
@Path("/test") public class ServiceInterface { @POST @Consumes(MediaType.MULTIPART_FORM_DATA) public void execute(@FormParam(value="someparameter") String param) { System.out.println(param); } }
When submitting a form, the value for "someparameter" is always indicated as null, but on the form I entered a value.
My questions:
- What is wrong with the code above?
- How do I access a file that is submitted using a form?
I am using Jersey 1.10.
source share