앱)java springframework select box jstl form sample 예제

Posted by HULIA(휴리아)
2018. 6. 11. 11:19 백엔드개발/자바스프링
<form name="searchForm" id="searchForm" method="post">

<select name="statusCode" id="statusCode" style="width:208px;" class="select">
         <option value="">ALL</option>
         <option value="R">R</option>
         <option value="R">R</option>
         <option value="R">R</option>
         <option value="R">R</option>
</select>


<select name="status" id="status">
              <option value="">ALL</option>
              <c:if test="${null != stsCdList && !empty stsCdList}">
                     <c:forEach var="stsCdList" items="${stsCdList}">
                           <option value="${stsCdList.code}">${stsCdList.codeName}</option>
                     </c:forEach>
              </c:if>
</select>



<select id="useType" name="useType" style="width:200px;">
      <c:if test="${null != useTpCdList && !empty useTpCdList}">
             <c:forEach var="useTpCdList" items="${useTpCdList}">
                     <c:if test="${useTpCdList.code != 'M' && useTpCdList.code != 'P'}">
                             <option value="${useTpCdList.code}">${useTpCdList.codeName}</option>
                      </c:if>
             </c:forEach>
</select>

<select class="select" name="historySelect" id="historySelect" onchange="showView()" style="width:150px;height:23px;">
           <option value="kkkk" <c:if test="${historyType eq 'kkkk'}">selected</c:if>>History</option>
           <option value="pppp" <c:if test="${historyType eq 'pppp'}">selected</c:if>>History</option>
</select>


</form>


function showView(){
      var selectVal = $('#historySelect').val();
      if(selectVal == "kkkk") {
                $.ajax({
                         url : "<c:url value='/showView.do' />",
                         type: 'post',
                         beforSend : function(xhr) {
                        xhr.setRequestHeader("AJAX","true");
                        },
                        data : {
                             key : "${}",
                             key2 : "D"
                        },
                        contentType : "application/x-www-form-urlencoded; charset=UTF-8",
                        success : function(data) {
                           $('#dkfkjf').val();
                           $('#dfkjfk').html(data);
                          },
                         error : function(xhr, status, err){
                  if(xhr.status==403) {
                            location.href="<c:url value='/login/intro.do' />";
                         }
                   }

             });
      }
}

@RequestMapping(value = "/showView", method = {RequestMethod.POST})
public ModelAndView showView(HttpServletRequest request, HttpServletResponse response){
           ModelAndView view = new ModelAndView();

           int pageNo = ParamUtil.param(request,"pageNo",null) == null? 1: Integer.parseInt(ParamUtil.param(request,"pageNo", null));

view.addObject("key", keyObject);
view.setViewName("kkkk/kkkk");

return view;

}