我想将我的span类值传递给spring mvc中的controller

时间:2017-07-24 07:40:17

标签: spring-mvc

我想将我的span类值传递给spring mvc中的controller。这是我的代码:

  $("#SscpreviewDiv").click(function(){
                       $("#myModal").modal('show');

                      var firstname=$("#firstname").val();
                      var middlename=$("#middlename").val();
                      var lastname=$("#lastname").val();

                     var datetimepicker=$("#datetimepicker").val();
                      //var datetimepicker=$('#datetimepicker :selected').attr("value");
                     var gender=$("#gender").val();
                      var contact=$("#contact").val();
                      var city=$("#city").val();
                      var pincode=$("#pincode").val();
                      var 
         phisically_challenged=$("#physically_challenged").val();
                      var category=$("#category").val();
                      var ssc_marks=$("#ssc_mark").val();

          $(".firstname").text(firstname);
                      $(".middlename").text(middlename);
                      $(".lastname").text(lastname);

                     $(".datetimepicker").text(datetimepicker);
                     $(".gender").text(gender);
                      $(".contact").text(contact);
                       $(".city").text(city);
                      $(".pincode").text(pincode);


<form:form action="saveSscDetailsonPreview" 
    modelAttribute="sscAdmissionProcessBean"  method="Post">       
    <div class="divborder "  style="padding-left: 15px;" >
    <div class="detailsBorder"  align="center">
       <strong><i><span class="fullname"></span></i></strong></h3>
       <div class="col-10 varela ">
            <table  class="table-hover table table-striped table-bordered" >
                <thead style="color: black" id="examtable" >
                <tr><th width="50%;">Firstname</th><td> <span  class="firstname" id="firstname" ></span></td></tr>
                         <tr><th width="50%;">Middlename</th><td> <span class="middlename"></span></td></tr>
                         <tr><th width="50%;">Lastname</th><td> <span class="lastname"></span></td></tr> 
                         <tr><th>date Of Birth</th><td> <span class="datetimepicker"></span></td></tr>   
                         <tr><th>Contact</th><td><span class="contact"></span></td></tr>
                         <tr><th>Gender</th><td><span class="gender"></span></td></tr>
                         <tr><th>Category</th><td><span class="category"></span></td></tr>
                         <tr><th>City</th><td><span class="city"></span></td></tr>
                         <tr><th>SSC Marks</th><td><span class="ssc_mark"></span></td></tr>
                         <tr><th>Passing Year</th><td><span class="monthyear"></span></td></tr>
                         <tr><th>Course</th><td><span class="ssc_select_course"></span></td></tr>
                         <tr><th>Stream</th><td><span class="ssc_select_stream"></span></td></tr>
                         <tr><th>Physically Challenge</th><td><span class="phisically_challenged"></span></td></tr>
                         <tr><th>Mode</th><td><span class="select_mode"></span></td></tr>
                         <tr><th>ApplyDate</th><td><span 
   class="sscApplyDate"></span></td></tr> 
                </thead>
            </table>``
            </div>
      </div>
 <button id="savePreviewDetails">Print Your Form</button>  
      </div>
    </form:form>

 im setting text field value into span class using ajax and display model 
 class but i after display im trying to save span class  to controller value getting null plz tell me what happen?

使用ajax和显示模型将文本字段值设置为span类      类,但我显示后我试图将span类保存到控制器值获取null plz告诉我使用ajax和显示模型将我的文本字段值设置为span类      类,但我显示后我试图将span类保存到控制器值获取null plz告诉我使用ajax和显示模型将我的文本字段值设置为span类      类,但我显示后我试图将span类保存到控制器值获取null plz告诉我使用ajax和显示模型将我的文本字段值设置为span类      类,但我显示后我试图将span类保存到控制器值获取null plz告诉我使用ajax和显示模型将我的文本字段值设置为span类      类,但我显示后我试图将span类保存到控制器值获取null plz告诉我使用ajax和显示模型将我的文本字段值设置为span类      类,但我显示后我试图将span类保存到控制器值获取null plz告诉我什么h

1 个答案:

答案 0 :(得分:0)

<span>不是inputSelect。您应该使用inputSelect向Controller发送值。

尝试添加额外的hidden字段并设置为值。

e.g。

<strong><i><span class="fullname">
    <input type="hidden" name="fullname" id="id-fullname">
    //OR
    <form:hidden path="fullname">
</span></i></strong>

在jQuery中

$('id-fullname').val(fullname);