开发者

If you use a regular HTML <form> tag instead of the Spring <form:form> tag, how do you specify where it's submitted?

In the Spring docs, the section on multipart support has an example of specifying a multipart form as this:

<form method="post" action="upload.form" enctype="multipart/form-data">

This doesn't use the Spring form tags which I am familiar with and instead submits the form to the upload.form action.

How does Spring know what uplo开发者_StackOverflow社区ad.form means? Do you have to create a mapping for it and, if so, where is this done?


upload.form is the URL of the HTTP POST request that is created by this form. It will be relative to the URL of the view that generated the form in the first place, so if the form shown above is rendered by /mysite/myapp/myform.html, it will submit to /mysite/myapp/upload.form

It then becomes a matter of configuring Spring to handle "/upload.form" request accordingly, such as through @RequestMapping if you're using annotation-based Spring MVC. See here for more information.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜