使用setProperty分配值

时间:2014-10-18 10:42:14

标签: jsp usebean

我创建了一个具有<jsp:useBean>的JSP页面。问题在于,无论何时提交表单,testName的值在bean中都是null,在timLim中都是相同的。

<form method="POST" action="test-panel.jsp">
                        <table>
                        <tr>
                        <td>
<input style="width:300px" name="testName" type="text" required pattern="[0-9 A-Za-z\\s]*" maxlength="100">
                        </td>
                        <tr>
                        <td>
<input style="width:100px" name="timLim" type="text" pattern="[0-9\\s]*" required maxlength="3">
                        </td>
                        <tr>
                        <td>
                        <div style="width:100px">
                            <select name="queRand">
                                                <option value="1">Yes
                                                </option>
                                                <option value="0">No
                                                </option>
                        </select>
                        </div>
                        </td>
                        </tr>
                        <tr>
                        <td>
                            <input type="submit" value="Next">
                        </td>
                        </tr>
                        </table>
                      </form>
    <jsp:useBean class="pack1.TD1" id="td2" scope="request"></jsp:useBean>
    <jsp:setProperty name="td2" property="testName" param="testName"></jsp:setProperty>
    <jsp:setProperty name="td2" property="timLim" param="timLim"></jsp:setProperty>
    <jsp:setProperty name="td2" property="queRand" param="queRand"></jsp:setProperty>
    <%
        td2.saveTestDetails(false);
    %>

0 个答案:

没有答案