Spring MVC标签

1、我们平时使用表单的时候,一般都是这样:

<form id="form" action="Login.do" method="post">
<table>
    <tr>
        <td>First Name:</td>
        <td><input id="firstName" name="firstName" type="text"></td>
    </tr>
    <tr>
        <td>Last Name:</td>
        <td><input id="lastName" name="lastName" type="text"></td>
    </tr>
    <tr>
        <td colspan="2">
            <input type="submit" value="Save Changes">
        </td>
    </tr>
<table>
</form>

2、自从Spring2.0开始,Spring Framework 提供了from表单的标签库。

标签库的引入:

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<form:form>
    <table>
        <tr>
            <td>First Name:</td>
            <td><form:input path="firstName"/></td>
        </tr>
        <tr>
            <td>Last Name:</td>
            <td><form:input path="lastName"/></td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="submit" value="Save Changes"/>
            </td>
        </tr>
    </table>
</form:form>

Reference:

[1] Spring Framework Reference Documentation, http://docs.spring.io/spring/docs/4.2.9.RELEASE/spring-framework-reference/htmlsingle/#view-jsp-formtaglib

posted @ 2017-07-06 09:01  ryelqy  阅读(159)  评论(0编辑  收藏  举报