


Detailed explanation of the selected attribute when converting into in html
1. Concept introduction
The use of html tags in stust1, including html:select, html:option, details are as follows
<html:select property="test String " size="1"> <html:option value="value1">Show Value1</html:option> <html:option value="value2">Show Value2</html:option> <html:option value="value3">Show Value3</html:option> <:html:submit property="submit" value="提交"/> </html:select>
Among them, property represents the corresponding property name in the selection list and ActionForm. When the user clicks submit, the value of the option selected by the user will be seen on the test page. The following is the running effect of the code:
Show Value1 Show Value2 Show Value3
The following is an example of multiple="true" and size="8"
value1 value2 value3 value4 value5 value6 value7 value8 value9 value10
When the multiple attribute is true, in The corresponding property in ActionForm should be an arraytype so that multiple values selected by the user can be assigned to it at the same time.
<html:select property="testString" size="1"> <html:option value="value1">Show Value1</html:option> <html:option value="value2">Show Value2</html:option> <html:option value="value3">Show Value3</html:option> </html:select>
An option has two important parts. The first is the content it displays to the user, which can be specified in the following way:
<html:option value="value1">Show Value1</html:option>
As can be seen, the part between two
Another important content is the value it passes to ActionForm. This is specified by the tag's value attribute. As in the above example, the values of value are value1, value2 and value3 respectively. When the user selects a certain tag, the JSP page will pass the value corresponding to the tag to the corresponding attribute in the ActionForm.
The following is the running effect:
Show Value1 Show Value2 Show Value3
2. Secrets that cannot be told
<html:option></html:option>转化成<option></option>时加了selected属性,RTFSC,看源码 if(selectTag().isMatched(value)) results.append(" selected=\"selected\""); public boolean isMatched(String value) { /* <-MISALIGNED-> */ /* 126*/ if(match == null || value == null) /* <-MISALIGNED-> */ /* 127*/ return false; /* <-MISALIGNED-> */ /* 130*/ for(int i = 0; i < match.length; i++) /* <-MISALIGNED-> */ /* 131*/ if(value.equals(match[i])) /* <-MISALIGNED-> */ /* 132*/ return true; /* <-MISALIGNED-> */ /* 135*/ return false; } if(value != null) {/* 234*/ match = new String[1]; /* 235*/ match[0] = value; } else { /* 238*/ Object bean = TagUtils.getInstance().lookup(super.pageContext, name, null); /* 239*/ if(bean == null) {/* 240*/ JspException e = new JspException(messages.getMessage("getter.bean", name)); /* 243*/ TagUtils.getInstance().saveException(super.pageContext, e); /* 244*/ throw e; } /* 248*/ try { /* <-MISALIGNED-> */ /* 248*/ match = BeanUtils.getArrayProperty(bean, property); //获取form中的select的value值 /* <-MISALIGNED-> */ /* 249*/ if(match == null) /* <-MISALIGNED-> */ /* 250*/ match = new String[0]; } /* 254*/ catch(IllegalAccessException e) { /* <-MISALIGNED-> */ /* 254*/ TagUtils.getInstance().saveException(super.pageContext, e); /* <-MISALIGNED-> */ /* 255*/ throw new JspException(messages.getMessage("getter.access", property, name)); }
3. Unsolved problems, how to set the default selection using html:option, there is no selected attribute
The above is the detailed content of Detailed explanation of the selected attribute when converting into in html. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.
