spring提供了两个标签库文件:spring-form.tld(表单标签库,用于输出HTML表单)  spring.tld(基础标签库,用于Spring数据绑定等)

使用步骤:

1,配置表单标签库,复制spring.tld到\WEB-INF目录下,并在web.xml中添加该标签库的引用:

<jsp-config>
    <taglib>
        <taglib-uri>/spring-form</taglib-uri>
        <taglib-location>/WEB-INF/spring-form.tld</taglib-locatioin>
    </tablib>
</jsp-config>

2,在JSP文件中引入标签:

 <%@taglib prefix="form" uri="/spring-form"%>

3,在request中保存JavaBean.

 1 public class User {
 2 
 3     private String username="admin";
 4     private String password="1243";
 5     private String [] interests= {"Structs","Hibernate","Spring"};
 6     private String sex="M";
 7     public String getUsername() {
 8         return username;
 9     }
10     public void setUsername(String username) {
11         this.username = username;
12     }
13     public String getPassword() {
14         return password;
15     }
16     public void setPassword(String password) {
17         this.password = password;
18     }
19     public String[] getInterests() {
20         return interests;
21     }
22     public void setInterests(String[] interests) {
23         this.interests = interests;
24     }
25     public void setSex(String sex) {
26         this.sex = sex;
27     }
28     
29 }
View Code

相关文章:

  • 2021-07-15
  • 2021-09-01
  • 2022-12-23
  • 2021-10-30
  • 2022-12-23
  • 2021-10-02
  • 2021-05-16
猜你喜欢
  • 2021-06-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-04
  • 2022-03-02
  • 2022-12-23
相关资源
相似解决方案