error HTTP Status 400 – after form submission

first of all I have two tables job, category which are in diagram as

Job to Cat

and my entities are :

@Table( name = TableName.JOB_TABLE)
public class Job {

    private Integer id;

    private String title;

    private String description;     

    @OneToMany(mappedBy = "job")
    private List<Category> categories;

    // omitting setters an getters for brevity  



@Table( name = TableName.CATEGORY_TABLE)
public class Category {

    private Integer id;

    private String name;

    @JoinColumn(name = "job_id")
    private Job job;

    // omitting setters an getters for brevity  


JobService is

public class JobService implements IDatabaseCrud<Job>{

    private JobRepository jobRepository;

    private CategoryRepository categoryRepository;

    public void save(Job obj) {
        // TODO Auto-generated method stub;

JobRepository is

public interface JobRepository extends JpaRepository<Job, Integer> {


now I don’t have any idea to save new job using the form

<form:form commandName="job">
   <form:input path="title"/><br>
    <form:input path="company"/><br>
    <form:input path="location"/><br>
    <form:input path="url"/><br>
    <form:input path="email"/><br>
    <form:input path="description"/><br>
    <form:select path="categories">
    <form:options items="${categories}" itemValue="id" itemLabel="name"/>
    <form:input path="createdAt"/><br>
    <form:input path="toApply"/><br>
    <input type="submit" value="Add Job">

with the following controller I want to save these details to DB

public class JobController {

    private JobService jobService;

    private CategoryService categoryService;

    public Job constructJob() {
        return new Job();

    @RequestMapping(value = "/show-add-job", method = RequestMethod.GET)
    public String showJobForm(Model model) {
        model.addAttribute("categories", categoryService.findAll());
        return "add-job";

    @RequestMapping(value = "/show-add-job", method = RequestMethod.POST)
    public String addJobDetail(@ModelAttribute("job") Job job) {;
        return "redirect:/jobs";


with the above stuff when I submit the form I get HTTP Status 400.
This is URL to that project.

Source: forms

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.