Form processing in spring (17)

Form processing is very common in actual development, such as login, registration, addition, modification and so on.

I hope this example can improve and help beginners

This form example mainly describes MVC, which is equivalent to the submission of the foreground form. The submission is equivalent to an HTTP request. This request is mapped to the corresponding @ requestmapping through the controller, and the corresponding @ requestmapping value, that is, the route, is found. After the route processing, the data is returned to the foreground display in the form of model, modelandview or modelmap.

Example explanation:

1、 Import dependency

2、 Write corresponding entity

3、 Write the corresponding controller

Modelmap is the same as modelandview. The data is returned to the foreground in the form of key value pairs. The foreground only needs to know the corresponding key to obtain the corresponding value.

Of course, in terms of the separation of view and data, try not to use modelandview, and try to use model or modelmap.

4、 Writing JSP files

student. jsp

result. jsp

5、 Helloweb servlet xml

6、 Modify web xml

7、 Start application

The results are shown in the figure below:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>