![](/img/trans.png)
[英]Is there a better way to check for null in HttpServletRequest.getParamter()
[英]getParamter() returns NULL
為什么是request.getParameter("termin");
返回NULL
。我的數據庫的Connection和Statement是正確的,在更簡單的Version中可以正常工作。 這是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);
這是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">×</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>
我不是Bootstrap專家,但我可以看到一些導致此問題的潛在原因:
data-dismiss="modal"
-查看: http : //getbootstrap.com/javascript/#modals-related-target似乎data-dismiss="modal"
僅與“關閉”按鈕一起使用-從未與“提交”一起使用“!
類class="btn btn-primary"
應該與button
類型的元素一起使用,並且您將其與input
使用id
屬性可能會與bootstrap自動生成的html元素產生沖突,但我只是根據您上面的評論在這里猜測。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.