开发者

Spring mvc tag question

开发者 https://www.devze.com 2023-03-23 21:19 出处:网络
What is the significance \'label\' and \'path\' in the spring mvc jsp tag: form:label path=\"someName\"

What is the significance 'label' and 'path' in the spring mvc jsp tag:

form:label path="someName"
开发者_JAVA百科


label simply defines the text of the field within the page, for example:

<form:select path="dataVisArray"><br />
     <form:option label="Select..." value=""/>
     <form:options items="${dataVisArray} itemLabel="label" itemValue="value"/>
</form:select>

shows a dropdown, where the first element is "Select..." and the rest is defined in ${dataVisArray}

path links to a form backing object where you can save the input. In the example above, there would be a variable called "dataVisArray" within the backing object to save the value of the selected item once the form is submitted.


The label attribute is for displaying text corresponding to the form element for which we are using the label attribute

<label for="FirstName" >First Name :</label> 

For Path attribute can be also used in validation of form element by jquery

<form:input path="name" id="name" name="name"/>

The path value name then can be used for validation purpose:

$("#ajaxForm").validate({
     rules: {
         name: {
                required:true,
                minlenght:3

            },
      messages: {
            name : {
            required : 'Enter Username',
            maxlength :'Not more than 30 Charachters',
            minlength :'Should be more than 3 characters'
        }, 

Hope this helps.


In Spring MVC JSP tag lable signifies the value to be displayed as part of the tag and path is used to signify path to property for data binding.

<form:label path="company"> Enter company name: </form:label>
0

精彩评论

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

关注公众号