简体   繁体   English

getParamter()返回NULL

[英]getParamter() returns NULL

Why is request.getParameter("termin"); 为什么是request.getParameter("termin"); returning NULL .The Connection and the Statement for my Databse are correct.It works fine in an more simple Version. 返回NULL 。我的数据库的Connection和Statement是正确的,在更简单的Version中可以正常工作。 This is JSp/JAva Code: 这是JSp / JAva代码:

int result = 0;
if(request.getParameter("submit") != null) {
    String name = new String();

    if(request.getParameter("termin") != null) {
        name = request.getParameter("termin");

    }else {
        out.println("termin is null");
    }
    Termin t1 = new Termin();
    result = t1.setTermin(name);

Here is the HTML Code : 这是HTML代码:

<form action="index.jsp" method="POST" name="test">
    <div class="modal fade" id="bModal" tabindex="-1" role="dialog" aria-labelledby="beispielModalLabel" aria-hidden="true">

        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Schließen</span></button>
                    <h4 class="modal-title" id="beispielModalLabel">Neuer Termin</h4>
                </div>
                <div class="modal-body">
                    <!-- <form role="form" action="index.jsp" method="POST"> -->
                        <div class="form-group">
                            <label for="empfaenger-name" class="control-label">Name</label>
                            <input type="text" class="form-control" id="empfaenger-name" name="termin" value="">
                        </div>
                        <div class="form-group">
                            <label for="nachricht-text" class="control-label">Zusätzlich:</label>
                            <textarea class="form-control" id="nachricht-text"></textarea>
                        </div>
                    <!--  </form> -->
                </div>
                <div class="modal-footer">          
                    <button type="button" class="btn btn-danger" id="del" data-dismiss="modal" >Löschen</button>
                    <input type="submit" name="submit" class="btn btn-primary" id="eintrag" data-dismiss="modal" value="Speichern" >
                </div>
            </div>
        </div>

    </div>
</form> 

I'm not a Bootstrap expert yet I can see a few potential causes to this issue: 我不是Bootstrap专家,但我可以看到一些导致此问题的潜在原因:

  • data-dismiss="modal" - looking at: http://getbootstrap.com/javascript/#modals-related-target it seems that data-dismiss="modal" is used only with "close" buttons - never with "submit"! data-dismiss="modal" -查看: http : //getbootstrap.com/javascript/#modals-related-target似乎data-dismiss="modal"仅与“关闭”按钮一起使用-从未与“提交”一起使用“!

  • the class class="btn btn-primary" is supposed to be used with elements of type button and you're using it with input class="btn btn-primary"应该与button类型的元素一起使用,并且您将其与input

  • using the id attribute might create a conflict with bootstrap autogenerated html-elements, but I'm just guessing here based on your comment above. 使用id属性可能会与bootstrap自动生成的html元素产生冲突,但我只是根据您上面的评论在这里猜测。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM