Reputation: 9522
I am new to JAX-RS and so far I have created a simple CRUD REST service for my model Entity
which has some String
and Float
attributes.
Right now this is how I can create a new Entity
:
@Path("/entities")
public class EntityController {
@POST
@Consumes({"application/json"})
@Produces({"application/json"})
public Entity createEntity(Entity entity) {
if (EntityDAO.createEntity(entity) return entity,
else return null;
}
}
And this works just fine.
However, as I go forward into this API I would like to be able to make a simple form (in jsp I guess) to submit and create a new Entity
.
I have seen some answers to similar problems here, here, here or here. However, as I am new to JAX-RS and web services actually, I cannot decipher what's going on.
I would like some help and I'd really appreciate if you could point out all the components that take part into the given solution in case I am missing an obvious step.
Upvotes: 1
Views: 702
Reputation: 14348
Just use @FormParam
to inject form data:
@POST
@Consumes("application/x-www-form-urlencoded")
@Produces("...")
public Entity proceedForm(@FormParam("name") String name,
@FormParam("age") int age) {
// ...
}
Upvotes: 1