我试图通过提交表单来传递值,但是在提交时我看不到任何通过 URL 传递的数据。记录器已确认。
JavaScript 代码
函数 validateSelectedCombination() {
var program_Id = document.getElementById('id_select_program').value;
alert(program_Id);
document.getElementById('id_select_program').value;
document.getElementById("programFormDropDown").action=("../hDashBoard/project");
document.getElementById("programFormDropDown").submit();
}
JSP文件中的表格
<form id="programFormDropDown">
<label>Program :</label>
<select id="id_select_program" class="selectpicker" data-live-search="true" title='Choose Program...'>
<c:forEach var="program" items="${programs}">
<option value="${program.programId}">${program.programName}</option>
</c:forEach>
</select>
<input type="button" onclick="validateSelectedCombination()" value="Submit">
控制器
@RequestMapping(value = "/project" , method = RequestMethod.GET)
public ModelAndView programValidate(HttpServletRequest request , ServletResponse response) throws Exception {
String programId = request.getParameter("id_select_program");
LOGGER.info("Selected program id" + programId);
ModelAndView fileConfigModelView = new ModelAndView("fileUpload");
return fileConfigModelView;
}