2017-02-16 58 views
0

我在春JSP形式的工作,但我有困難與「後」的方法提交..
我的形式如下:春天,表單不會提交

<c:url var="action2" value="/saveConfig/try" /> 
<form:form name="formakonfig" id="formakonfig" action="${action2}" method="post" modelAttribute="seatingConfiguration"> 
     <form:hidden path="mesto" id="mestoo" value=""></form:hidden> 
     <form:hidden path="restoran" id="restoranre" value=""></form:hidden> 
     <form:hidden path="reon" id="reonn" value=""></form:hidden> 
     <form:hidden path="raspolozivost" id="raspolozivostt" value=""></form:hidden> 
    </form:form> 
    <button type="submit" style="width: 152px; height: 25px; margin-top:-60px; margin-left:150px; position:fixed;">Sacuvaj konfiguraciju</button> 

我有JavaScript文件,我在哪裏設置隱藏字段的值"mesto""restoran","reon""raspolozivost",內部爲$(document).ready

$("#mestoo").val(stringSadrzajaTabele); 
$("#restoranre").val(vrednostSelekta()); 
$("#reonn").val(stringSadrzajaTabele); 
$("#raspolozivostt").val("slobodno"); 

我也有控制器在那裏我試圖訪問(但我不能訪問它。)

@RequestMapping(value="/saveConfig/try",method=RequestMethod.POST) 
    public ModelAndView snimanjeKonfiguracije(@Valid SeatingConfiguration seatingConfiguration,BindingResult bindingResult,ModelMap model,HttpServletRequest request){ 

     if (bindingResult.hasErrors()) {  
      return new ModelAndView("zaposleni","formErrors",bindingResult.getAllErrors()); 
     } 
     model.addAttribute("workerRegistration", new WorkerRegistration()); 
     model.addAttribute("restaurantRegistration", new RestaurantRegistration()); 

     String temp1=seatingConfiguration.getMesto(); 
     String temp2=seatingConfiguration.getRestoran(); 
     String temp3=seatingConfiguration.getReon(); 
     String temp4=seatingConfiguration.getRaspolozivost(); 
     System.out.println(temp1); 
     System.out.println(temp2); 
     System.out.println(temp3); 
     System.out.println(temp4); 

     model.put("poruka", "Dodato!"); 
     return new ModelAndView("zaposleni","model",model); 
    } 

是否有人有耐心誰在春天的工作,看看什麼是可能的問題?這對我意味着很多!:)無論如何,謝謝!

+0

你有什麼確切的問題?當你點擊提交時,404錯誤或不會發生? –

+0

沒有任何反應,當我提交..我有類似的形式,但在那裏我有事件select.onchange,並在那裏我把$()。val()..在這裏我把它放在點擊(功能(){}),爲了使頁面上的某些東西被點擊時,我可以提交信息,點擊它,並把它隱藏的id值,然後傳遞給控制器​​..如果它有可能以某種方式..在這種形式的工作,但在這裏它贏得了't – slomilll

回答

0

在第一個代碼中,如果您沒有通過js發送表單,那麼您的提交按鈕不在表格中,應該是這種情況。 PLace提交按鈕內的表單元素如下:

<form:form name="formakonfig" id="formakonfig" action="${action2}" method="post" modelAttribute="seatingConfiguration"> 
     <form:hidden path="mesto" id="mestoo" value=""></form:hidden> 
     <form:hidden path="restoran" id="restoranre" value=""></form:hidden> 
     <form:hidden path="reon" id="reonn" value=""></form:hidden> 
     <form:hidden path="raspolozivost" id="raspolozivostt" value=""></form:hidden> 
     <button type="submit" style="width: 152px; height: 25px; margin-top:-60px; margin-left:150px; position:fixed;">Sacuvaj konfiguraciju</button> 
    </form:form> 
+0

謝謝!! :))) – slomilll

+0

不客氣,我的朋友:) –