[英]Retrieve jsp value in servlet
I have a problem with the recovery of the values of my JSP in my Servlet. 我在Servlet中恢复JSP值时遇到问题。
My JSP contains one input and two select. 我的JSP包含一个输入和两个选择。
I would like to retrieve the values of these elements and pass them in my servlet, but the result in my servlet is still null. 我想检索这些元素的值并将它们传递到我的servlet中,但是我的servlet中的结果仍然为null。
String histoDate = request.getParameter("cDate");
String intervalleHeure = request.getParameter("cHeure");
String statut = request.getParameter("cStatut");
And in my JSP I create these elements in jQuery 在我的JSP中,我在jQuery中创建了这些元素
"<label>Date : <input class='form-control' type='text' value='05/07/2018' placeholder='Cliquer pour choisir' id='histoDate' name='histoDate'> </label>"
"<label>Heure : <select id='demo-foo-filter-nbTrame' class='form-control selectpicker' id='intervalleHeure' name='intervalleHeure'>"
"<select id='demo-foo-filter-status' class='form-control selectpicker' id='statut' name='statut'>"
And I try to access my servlet with a function and I pass in argument the necessary values 我尝试使用一个函数访问我的servlet,然后将必要的值传递给参数
function valeurHistorique(cDate, cHeure, cStatut){
$.ajax({
dataType: "json",
url: "/Production/Maintenance/JSONHistorique",
data: {
histoDate: cDate,
heure : cHeure,
statut : cStatut
},
My three values are still null in my servlet, I am really stuck. 我的三个值在我的servlet中仍然为空,我真的很困惑。 Thank you for your help
谢谢您的帮助
When you send ajax request parameters will be named as left part of object data. 发送ajax请求时,参数将被命名为对象数据的左侧部分。
histoDate, heure, statut . 历史日期,时间,法规 。
Try it: 试试吧:
String histoDate = request.getParameter("histoDate");
String intervalleHeure = request.getParameter("heure");
String statut = request.getParameter("statut");
Also if you could see all parameters in httpServletRequest.getParameterMap();
另外,如果您可以在
httpServletRequest.getParameterMap();
看到所有参数,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.