Jannik
Jannik

Reputation: 90

HTTP Status 400 - Spring MVC Error

I´m developing a webapp with Maven and Spring MVC. When submitting a button the HTTP Status 400- Error appears. The descriptions says: "The request sent by the client was syntactically incorrect."

This is my .jsp:

    <body>

    <form:form modelAttribute="circleUpForm" method="POST" action="" enctype="multipart/form-data">

        <!-- path gibt den Namen der member Variablen an -->
        Input-File (.pdf): <form:input path="file" type="file"/><br />  

        <input type="submit" value="Start Circle Up">

    </form:form>

</body>

And this are the relevant methods of my Controller:

@RequestMapping(value = "/CircleUp", method = RequestMethod.GET)
public String circleUpGet(Model model) {

    CircleUpForm circleUpForm = new CircleUpForm();
    model.addAttribute("circleUpForm", circleUpForm);

    // Eine einzelne .jsp wird returnt
    return "CircleUp";
}

// POST: CircleUp
@RequestMapping(value = "/CircleUp", method = RequestMethod.POST)
public String circleUpPost(HttpServletRequest request, Model model, //
        @ModelAttribute("circleUpForm") CircleUpForm circleUpForm) {

    return this.doUpload(request, model, circleUpForm);
}

This is my Form:

import org.pdfclown.files.File;

public class CircleUpForm {

    // private CommonsMultipartFile file;

    // File
    private File file;

    public File getFile() {
        return file;
    }

    public void setFile(File file) {
        this.file = file;
    }
}

The GET method works well, but when clicking on the submit button on my view the error appears. Thus I think something went wrong on my POST Method. I tried to debug the problem but not even the method is executed. I have just started programming with Spring MVC and I´m not really familiar with some concepts. Maybe someone has an idea? Thank you !

Upvotes: 0

Views: 153

Answers (1)

mffm
mffm

Reputation: 396

Remove the "enctype="multipart/form-data" tag from your .jsp.

Upvotes: 1

Related Questions