Use Spring's form labels
The Springmvc form label enables you to bind attributes in model data and HTML form elements to enable easier editing of form data and echo of form values .
Form label
In general, a form page is obtained through a GET request and the form page is submitted via a POST request, so the URL to get the form page and submit the form page is the same . As long as the contract that satisfies the best condition,<form:form> label does not need to specify the URL of the form submission through the Action property
The model property of the binding can be specified through the Modelattribute property, and if the property is not specified, the form bean that reads command from the request domain object is defaulted, and an error occurs if the property value does not exist.
Form Labels
SPRINGMVC provides multiple form component labels, such as <form:input/>, <form:select/>, to bind the attribute values of form fields, and their common properties are as follows:
Path: Form fields, corresponding to the Name property of the HTML element, support for cascading properties
Htmlescape: Whether to convert the HTML special character of the form value to the default value of True
CssClass: CSS style class name corresponding to form component
Csserrorclass: The CSS style taken when there is an error in the data of the form component
Form:input, Form:password, Form:hidden, Form:textarea: text, password, hidden, textarea tags corresponding to HTML forms
Form:radiobutton: a radio box component label that is selected when the form bean corresponds to a property value and a value equal
Form:radiobuttons: a radio box Group label for constructing multiple radio boxes
Items: Can be a List, string[], or Map
Itemvalue: Specifies the value of the radio. Can be a property value of a bean in a collection
Itemlabel: Specifies the label value of the radio
Delimiter: Multiple Radio boxes can specify delimiters by delimiter
Form:checkbox: check box component. Used to construct a single check box
Form:checkboxs: Used to construct multiple check boxes. Using the same form:radiobuttons label
Form:select: Used to construct a drop-down box component. Using the same form:radiobuttons label
Form:option: drop-down box option component label. Using the same form:radiobuttons label
Form:errors: Displays errors for the form component or data check
<form:errors path= "*"/>: Display all errors in the form
<form:errors path= "user*"/>: Displays all errors that correspond to the user-prefixed attribute
<form:errors path= "username"/>: Error displaying properties of specific form objects
Working with Static resources
1. Why is there such a problem:
The elegant REST-style resource URL does not want to have a. html or. do suffix. If the Dispatcherservlet request mapping is configured AS/, Spring MVC captures all requests for the WEB container, including requests for static resources, and SPRINGMVC treats them as a normal request, because the corresponding processor is not found and will result in an error.
2. FIX: Configure <mvc:default-servlet-handler/> in SPRINGMVC configuration file
<!-- Default-servlet-handler will define a defaultservlethttprequesthandler in the SPRINGMVC context, which will enter Dispatcherservlet Request, and if it is found to be a request that is not mapped, the request is processed by the WEB application server's default Servlet. If the request is not a static resource, the Dispatcherservlet continues to process the generic WEB application server The default servlet name is defaults. If the default servlet name for the Web server you are using is not defaulted, you need to pass the Def The Ault-servlet-name property explicitly specifies--><mvc:default-servlet-handler/>
SPRINGMVC form Labels & handling static resources