【问题标题】:Retrieve jsp value in servlet在servlet中检索jsp值
【发布时间】:2018-07-05 09:58:12
【问题描述】:

我在 Servlet 中恢复 JSP 的值时遇到问题。

我的 JSP 包含一个输入和两个选择。

我想检索这些元素的值并将它们传递到我的 servlet 中,但我的 servlet 中的结果仍然为空。

String histoDate = request.getParameter("cDate");
String intervalleHeure = request.getParameter("cHeure");
String statut = request.getParameter("cStatut");

在我的 JSP 中,我在 jQuery 中创建这些元素

"<label>Date : <input class='form-control' type='text' value='05/07/2018' placeholder='Cliquer pour choisir' id='histoDate' name='histoDate'>&nbsp;&nbsp;&nbsp;</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'>"

我尝试使用一个函数访问我的 servlet,并在参数中传递必要的值

function valeurHistorique(cDate, cHeure, cStatut){
        $.ajax({
            dataType: "json",
            url: "/Production/Maintenance/JSONHistorique",
            data: {
                histoDate: cDate,
                heure : cHeure,
                statut : cStatut
            },

我的 servlet 中的三个值仍然为空,我真的被卡住了。谢谢你的帮助

【问题讨论】:

    标签: java jquery jsp servlets


    【解决方案1】:

    当你发送ajax请求时,参数将被命名为对象数据的左边部分。

    histoDate、heure、statut

    试试看:

    String histoDate = request.getParameter("histoDate");
    String intervalleHeure = request.getParameter("heure");
    String statut = request.getParameter("statut");
    

    如果你能看到httpServletRequest.getParameterMap();中的所有参数

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-17
      • 2015-01-31
      • 2012-05-24
      • 2012-01-14
      • 2018-08-19
      • 1970-01-01
      • 2018-10-29
      • 2014-06-27
      相关资源
      最近更新 更多