这是HTML代码:
<div class="box d" >
<form action="/question.do" id="formsubmit">
<input type="text" class="box e" placeholder="">
<div class="box f" id="boxff">
<span id="docnum" >using javascript add function</span> /
<span id="answer" >using javascript add function</span> /
<span id="startIndex">using javascript add function</span>
</div>
<input type="button" name="formsubmits" class="login login-submit" value="something" onclick="formSubmit();">
</form>
</div>
这是Javascript代码:
function formSubmit()
{
var form = document.getElementById("formsubmit");
form.docid= document.getElementById("docnum").innerText;
form.answer= document.getElementById("answer").innerText;
form.answerstartindex= document.getElementById("startIndex").innerText;
form.submit();
}
这是控制器
@Autowired
private DocumentService documentService;
ModelAndView model = new ModelAndView("main");
@RequestMapping("/question.do")
private ModelAndView questionSubmit(@Valid QuestionVO questionVO, BindingResult result,
RedirectAttributes redirect, HttpServletRequest request, HttpServletResponse response) throws Exception {
Iterator iter = request.getParameterMap().keySet().iterator();
while(iter.hasNext())
System.out.println(iter.next());
return model;
}
控制台打印为空
javascript中的form.docid,form.answer,form.answerstartindex具有所需的结果。
如何将form.submit的结果传递给控制器?