这是我的代码
HTML
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
org.hibernate.exception.GenericJDBCException: Cannot open connection
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449)
org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:160)
org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:81)
org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1473)
com.fidzeal.fivebar.dao.RegUserDAOImpl.save(RegUserDAOImpl.java:35)
com.fidzeal.fivebar.HomeController.registercontroll(HomeController.java:271)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Unknown database 'test')
JS函数
<form class="vfr-validate"
id="intl-numbers-list-form" action="${formAction}" method="post">
<div id="ion_error_non_eligible_chooser">
<c:if test="${errorNonEligibleChooser == 'true'}">
<p>
<fmt:message key='com.vodafone.wlportal.portlet.ion.non.eligible.postpaid.crmt' bundle='${current_bundle}'/>
</p>
<br>
<a href="" class="btn btn-primary mr20">Vezi Oferte</a>
</c:if>
</div>
<div class="col-md-3">
<input id="input_phone_no" class="required width100 pull-left mb10 mobile_international"
type="text" maxlength="10"
value="" name="phone_no">
</div>
<div class="col-md-3">
<c:choose>
<c:when test="${fn:length(requestScope.listFnF) >= listFnFMax || errorNonEligibleChooser == 'true'}">
<button disabled="disabled" class="btn btn-primary disabled" id="ion_add"
data-wa="true"
data-wa-type="portlet"
data-wa-portlet-name='<fmt:message key="com.vodafone.wlportal.portlet.ion.wa.data.wa.portlet.name" bundle="${global_properties_bundle }"/>'
data-wa-portlet-facet='<fmt:message key="com.vodafone.wlportal.portlet.ion.wa.data.wa.portlet.facet.web" bundle="${global_properties_bundle }"/>'
data-wa-portlet-action='<fmt:message key="com.vodafone.wlportal.portlet.ion.wa.data.wa.portlet.action.add" bundle="${global_properties_bundle }"/>'
>
<fmt:message key="com.vodafone.wlportal.portlet.ion.add.fnf" bundle="${current_bundle}" />
</button>
</c:when>
<c:otherwise>
<button class="btn btn-primary browserion" id="ion_add"
onclick="return addFNFAction();"
data-wa="true"
data-wa-type="portlet"
data-wa-portlet-name='<fmt:message key="com.vodafone.wlportal.portlet.ion.wa.data.wa.portlet.name" bundle="${global_properties_bundle }"/>'
data-wa-portlet-facet='<fmt:message key="com.vodafone.wlportal.portlet.ion.wa.data.wa.portlet.facet.web" bundle="${global_properties_bundle }"/>'
data-wa-portlet-action='<fmt:message key="com.vodafone.wlportal.portlet.ion.wa.data.wa.portlet.action.add" bundle="${global_properties_bundle }"/>'
>
<fmt:message key="com.vodafone.wlportal.portlet.ion.add.fnf" bundle="${current_bundle}" />
</button>
</c:otherwise>
</c:choose>
</div>
</div>
</form>
问题是在IE 11上,表单提交了2次。
我尝试以function addFNFAction() {
//console.log("addFNFAction");
var form = $("#intl-numbers-list-form");
if (form.valid() == true) {
$('#ion_loader').show();
$('#ion_add').attr("disabled", true);
form.submit();
}
}
和onclick
两种方式制作onclick="return addFNFAction();"
,结果与提交的结果相同。
答案 0 :(得分:1)
这是因为你正在调用jQuery的submit方法,它再次调用提交处理程序。它可能导致对提交处理程序的递归调用
而是尝试调用dom的submit
方法,还需要从处理程序返回false
以停止按钮单击的默认操作;
function addFNFAction() {
//console.log("addFNFAction");
var form = $("#intl-numbers-list-form");
if (form.valid() == true) {
$('#ion_loader').show();
$('#ion_add').attr("disabled", true);
form[0].submit();
}
return false;
}
答案 1 :(得分:1)
基本上,浏览器正在进行表单提交,然后您的点击处理程序再次提交表单。 您应该删除按钮上的onclick处理程序,并将onsubmit处理程序添加到表单标记。
尝试将此作为您的初始表单标记: -
<form class="vfr-validate" id="intl-numbers-list-form" onSubmit=addFNFAction method="post">
您需要将JS功能更改为: -
function addFNFAction(event) {
//console.log("addFNFAction");
event.preventDefault();
var form = $("#intl-numbers-list-form");
if (form.valid() == true) {
$('#ion_loader').show();
$('#ion_add').attr("disabled", true);
form.submit();
}
}