2014-09-22 2 views
0

Spring MVC에서 애플리케이션을 작성 중이다. 검색 작업을 사용하고 jsp 결과를 표 형식으로 각 행의 라디오 단추로 표시하고 searchResult.jsp에있는 업데이트 단추를 사용하여 테이블의 선택된 행을 업데이트합니다. 그러나 업데이트 작업을 내 컨트롤러를 통해 수행 한 후에 업데이트 된 레코드로 동일한 searchResult.jsp으로 리디렉션하고 싶습니다. 나에게 검색 결과를 제공Spring MVC에서 다른 컨트롤러로 리다이렉트

제발 도와주세요 ....

그리고 내 첫 번째 컨트롤러는 인수로 @RequestParams를 사용합니다. 나는 go 인터넷 검색을 많이하고 동일한 검색 컨트롤러를 다시 호출하는 제안을 찾았지만 내 경우에는 작동하지 않기 때문에 나는 이것을 언급하고있다. 검색

내 JSP

<!-- sac search --> 
<div id="sacSearch"> 
    <div id="searchContact"> 
        <form:form class="form-horizontal paddingTop10" role="form" action="autoRestrictSACSearchResult.htm" id="autoRestSACForm" method="POST"> 
      <div class="form-group"> 
       <label id="sacLabel" for="sac" class="col-sm-3 control-label"><spring:message code="manage.barrying.sac" /></label> 
       <div class="col-sm-3"> 
        <input class="form-control" type="text" id="sac" name="sac"> 
       </div> 
       <label id="sacNameLabel" for="sacName" class="col-sm-3 control-label"><spring:message code="manage.barrying.sac.name" /></label> 
       <div class="col-sm-3"> 
        <input class="form-control" type="text" id="sacName" name="sacName" data-toggle="tooltip" data-placement="right" title="" 
         data-original-title="Wildcard search - use * symbol"> 
       </div> 
      </div> 
      <hr> 
      <div class="form-group paddingSide30 marginBottom0"> 
       <button type="submit" class="btn btn-default btnStyle floatRight"> 
        <spring:message code="manage.barrying.search" /> 
       </button> 
      </div> 
     </form:form> 
    </div> 
</div> 

@RequestMapping(value = /autoRestrictSACSearchResult, method = RequestMethod.POST) 
@CDBusinessProcess("ThirdPartySACSearch") 
public ModelAndView ThirdPartysearchUsingSAC(@RequestParam(value="sac") String sac, @RequestParam(value="sacName") String sacName){ 
    ThreadLocalResources.get().logger().logMessage(E2EMessageGroup.INFO, "ThirdPartySACSearch" + ": searchUsingAccount, sac = "+sac + ", sacName = "+sacName); 
    ModelAndView modelAndView = new ModelAndView();List<RestrictionBarryingDTO> restricBarryindSACList = null; 
    restricBarryindSACList = restrictBarryingService.thirdPartygetSACSearchList(sac, sacName); 
    modelAndView.setViewName("thirdPartySACSearchResult"); 
    modelAndView.addObject("restricBarryindSACList",restricBarryindSACList); 
modelAndView.addObject("sac",sac); 
modelAndView.addObject("sacName",sacName); 
    return modelAndView; 
} 

다시 thirdPartySACSearchResult.jsp 같은 형태가 검색에 대한 내 첫 번째 컨트롤러 :

 <form:form id="sacEditForm" role="form" 
    action="thirdPartyapplyRemoveBarryingforSac.htm" method="POST"> 
     <c:choose> 
    <c:when test="${not empty sac and not empty sacName}"> 
    <p> 
    <strong>Search results for Sales account Code:</strong> ${sac}<strong> 
    and Sales Account Name:</strong> ${sacName} 
    </p> 
    </c:when> 
    <c:when test="${not empty sac}"> 
    <p> 
    <strong>Search results for Sales Account Code:</strong> ${sac} 
    </p> 
     </c:when> 
    <c:when test="${not empty sacName}"> 
    <p> 
    <strong>Search results for Sales Account Name:</strong> ${sacName} 
    </p> 
    </c:when> 
    </c:choose> 
    <spring:message code="manage.barrying.apply.bar.to"/> 
    <div class="verticalDivider topScope historyFullWidth"> 
    <table class="tablesorter standardText stripedTableJS"> 
    <thead> 
    <tr class="greyBackground"> 
    <th scope="col" class="width10 hideBackgroundImage">&nbsp;</th> 
    <th scope="col"><spring:message code="manage.barrying.sac" /></br> 
    <sapn> & name</span></th> 
    <th scope="col"><spring:message code="manage.barrying.le.num" /></br> <span> & name</span></th> 
    <th scope="col"><spring:message code="manage.barrying.auto.rest.bar.flag" /></th> 
    </tr> 
    </thead> 
    <tbody> 
    <c:forEach items="${restricBarryindSACList}" var="searchResult" 
     varStatus="loop"> 
     <c:choose> 
      <c:when test="${loop.index eq 0}"> 
      <tr class="cellSelected"> 
      <td><input type="radio" id="option${loop.index}" 
        value="${loop.index}" name="index" checked="checked" /></td> 
     </c:when> 
     <c:otherwise> 
     <tr> 
     <td><input type="radio" id="option${loop.index}" 
        value="${loop.index}" name="index" /></td> 
     </c:otherwise> 
     </c:choose> 
     <td><span class="SAC">${searchResult.salesAccountCode}</span></br>${searchResult.salesAccountName} 
     </td> 
     <td><span class="leNum">${searchResult.legalEntityNumber}</span></br>${searchResult.legalEntityName} 
     </td> 
     <c:choose> 
     <c:when test="${searchResult.thirdPartyBaringFlag eq 'N'}"> 
     <td><span class="bar">Off</span></td> 
     </c:when> 
     <c:otherwise> 
     <td><span class="bar">On</span></td> 
     </c:otherwise> 
     </c:choose> 
     </tr> 
     </c:forEach> 
     </tbody> 
    </table> 
    <input type="hidden" id="bar" name="bar" value="" /> 
    <input type="hidden" id="code" name="code" value="" /> 
    <input type="hidden" id="leNum" name="leNum" value="" />  
    </div> 
    <hr> 
    <div id="apply"> 
     <input type="submit" class="btn btn-default btnStyle floatRight" id="sacFields4ClickB" value="Apply Bar"/> 
    </div> 
    <div id="remove">    
     <input type="submit" class="btn btn-default btnStyle floatRight" id="sacFields5ClickB" value="Remove Bar"/> 
    </div> 
    </form:form> 
</div> 

과의 컨트롤러를 다음과 같은 양식 ID :

 @RequestMapping(value="/thirdPartyapplyRemoveBarryingforSac", method=RequestMethod.POST) 
@CDBusinessProcess("AutoRestrictApplyRemoveBarr") 
//@RequestParam(value="sac") String sac,@RequestParam(value="applyRemoveFlag") String applyRemoveFlag,@RequestParam("searchType") String searchType, 
public ModelAndView thirdPartyapplyRemoveBarrying(@RequestParam(value="bar") String barFlag, @RequestParam(value="code") String sacCode,@RequestParam(value="leNum") String leNum,HttpServletRequest request) { 
    System.out.println("-----------------------Priting the requestParameterNames " + barFlag + " , " + sacCode +" , "+leNum); 
    System.out.println("#####################..................... Inside the controller method applyRemoveBarrying ...."); 
     ApplyRemoveBarryingDTO newone = new ApplyRemoveBarryingDTO(); 
     newone.setSacCode(sacCode); 
     newone.setLeCode(leNum); 
     newone.setRecordType(searchType); 
     newone.setAutoBarFlag(applyRemoveFlag); 
     System.out.println("#################........................... Calling the applyRemoveBarry method of the Service Class"); 
     StoredProcedureResult result = restrictBarryingService.thirdPartyapplyRemoveBarry(newone,userId); 
      if(result.isSuccess()) 
     { 
      modelAndView.addObject("isSuccess",true); 
     } else 
     { 
      modelAndView.addObject("isSuccess",false); 
     }    
     return modelAndView; 
} 

와 나는 타이어를 didplayed 된 첫 번째 형태로 전달 된 값에 대한 업데이트 된 결과를 표시해야합니다 autoRestrictSACSearchResult.jsp있는 첫 번째 페이지를 가고 싶어이 컨트롤러가 실행되면검색

내 JSP입니다
<!-- sac search --> 
    which is written above. 
+0

왜 'return'redict를하지 않는 것이 좋을까요? 뭐든간에 - 컨트롤러 매핑은 "업데이트 방법 안에 있습니까? – geoand

+0

업데이트 버튼을 클릭하면 perticular 컨트롤러로 이동 한 다음 searchResult 페이지로 이동하지만 처음 검색 할 때 사용한 값을 리디렉션에도 사용해야합니다. –

+0

관련 코드를 게시 할 수 있습니까? – geoand

답변

1
return new ModelAndView("redirect:/url"); 
+0

클릭 버튼을 클릭하면 perticular 컨트롤러로 이동 한 다음 searchResult 페이지로 이동하지만 처음 검색 할 때 사용한 값을 리디렉션에도 사용해야합니다 –

+0

URL을 게시 할 수 있습니까? searchResult에 처음으로 사용하고 있습니까? – RE350

관련 문제