Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从jquery或javascript更改表单的modelAttribute?_Javascript_Jquery_Html_Spring_Spring Mvc - Fatal编程技术网

如何从jquery或javascript更改表单的modelAttribute?

如何从jquery或javascript更改表单的modelAttribute?,javascript,jquery,html,spring,spring-mvc,Javascript,Jquery,Html,Spring,Spring Mvc,我正在使用HTML5和SpringMVC开发一个应用程序 最初显示一个表,单击一行时,表单应作为对话框填充,并在表单属性中填充该行的特定数据 所以我实际上需要的是单击该表单的modelArrtibute行,该行应该从jquery或javascript设置 <div class="form-group"> <form:label path="smtpServer" for="s

我正在使用HTML5和SpringMVC开发一个应用程序

最初显示一个表,单击一行时,表单应作为对话框填充,并在表单属性中填充该行的特定数据

所以我实际上需要的是单击该表单的modelArrtibute行,该行应该从jquery或javascript设置

                        <div class="form-group">
                            <form:label path="smtpServer" for="serialNumber"
                                class="col-sm-3 col-sm-offset-2 control-label">SMTP Server</form:label >
                            <div class="col-sm-5">
                                <form:input path="smtpServer" type="text" class="form-control" id="serialNumber" name="smtpserver"
                                    placeholder="SMTP Server" />
                            </div>
                        </div>
                        <div class="form-group">
                            <form:label path="portNumber" for="serialNumber"
                                class="col-sm-3 col-sm-offset-2 control-label">Port
                                Number</form:label >
                            <div class="col-sm-5">
                                <form:input path="portNumber" type="text" class="form-control" id="serialNumber"
                                    placeholder="Port Number" />
                            </div>
                        </div>
                        <div class="col-sm-offset-4">
                            <p>
                            <h5>
                                <form:checkbox path="issmtpEnabled" value="1"/>Enable SMTP Authentication
                            </h5>
                            </p>
                        </div>

                        <div class="form-group">
                            <form:label path="fromAddress" for="serialNumber"
                                class="col-sm-3 col-sm-offset-2 control-label">From
                                Email Address</form:label >
                            <div class="col-sm-5">
                                <form:input path="fromAddress" type="text" class="form-control" id="serialNumber"
                                    placeholder="From Email Address" />
                            </div>
                        </div>
                        <div class="modal-footer">
                            <input type="submit" class="btn btn-primary" value="Apply" />
                        </div>
                    </form:form>


不能更改spring标记的modelAttribute


为什么?因为在呈现响应时,spring的标记将被转换为HTML中的普通标记,并且不再包含modelAttribute,所以modelAttribute将被转换为名称和id(即,modelAttribute的名称将被赋予HTML表单标记中的名称和id属性)

为什么您认为可以使用javascript设置JSP标记属性?
<table class="table table-hover">
    <thead>
        <tr class="active">
            <th>SMTP Server</th>
            <th>Port Number</th>
            <th>Sender Email</th>                                               
            <th>Use SSL/TLS Secure Connection</th>

        </tr>
    </thead>
    <tbody>
        <c:forEach var="PT"
            items="${alertSettingsManagement.emailSettingsAlertList}">
            <tr id="${PT.id}" class="emailSettingsRow">
                <td>${PT.smtpServer}</td>
                <td>${PT.portNumber}</td>
                <td>${PT.fromAddress}</td>                                                  
                <td>${PT.issslEnabled == 1 ? 'Yes' : 'No'}</td>                                                 
            </tr>
        </c:forEach>
    </tbody>
</table>
$('.emailSettingsRow').click( function() {
                   //want to set modelAttribute here
          var row = $(this).find('td:first').text();          
          $('#emailModal').modal('show');
    });