嗨我做了一個if查詢,並且這個問題發送到服務器。但是,服務器將只接受2個數字和一個十進制數字(99.9),但我必須計數到100,服務器總是給我一個錯誤。 你知不知道我可以怎麼捕捉這個錯誤,以至於我的軟件無論如何Counts爲100.它不能輸出到服務器。該程序只能運行。他不讓它在99再次停止,並繼續倒計時所以當他正值99,然後100我不能發現錯誤
公共靜態無效的主要(字串[] args) {
boolean positive = true;
int counter = 0;
while (true)
{
if (counter >= 99)
{
positive = false;
}
if (counter <=-99)
{
positive = true;
}
if (positive == true)
{
counter ++;
}
else
{
counter --;
}
這是我的「軟件「例外是:
Exception = Response was of unexpected text/html ContentType. Incoming portion of HTML stream: <html><head><title>Apache Tomcat/7.0.47 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - Request processing failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/QueryTimeoutException</h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u>Request processing failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/QueryTimeoutException</u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/QueryTimeoutException
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:948)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:186)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
</pre></p><p><b>root cause</b> <pre>java.lang.NoClassDefFoundError: org/springframework/dao/QueryTimeoutException
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.<init>(SQLErrorCodeSQLExceptionTranslator.java:86)
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.<init>(SQLErrorCodeSQLExceptionTranslator.java:102)
org.springframework.jdbc.support.JdbcAccessor.getExceptionTranslator(JdbcAccessor.java:99)
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:605)
org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:849)
org.springframework.jdbc.core.simple.AbstractJdbcInsert.executeInsertAndReturnKeyHolderInternal(AbstractJdbcInsert.java:436)
org.springframework.jdbc.core.simple.AbstractJdbcInsert.executeInsertAndReturnKeyInternal(AbstractJdbcInsert.java:417)
org.springframework.jdbc.core.simple.AbstractJdbcInsert.doExecuteAndReturnKey(AbstractJdbcInsert.java:371)
org.springframework.jdbc.core.simple.SimpleJdbcInsert.executeAndReturnKey(SimpleJdbcInsert.java:122)
de.fraunhofer.iao.sharedefleet.energiemanagement.backend.ChargePointLogDAO.insertChargePointRequest(ChargePointLogDAO.java:65)
de.fraunhofer.iao.sharedefleet.energiemanagement.facade.PlugAndChargeFacade.handleHeartbeatRequest(PlugAndChargeFacade.java:55)
de.fraunhofer.iao.sharedefleet.energiemanagement.facade.PlugAndChargeFacade.requestChargingState(PlugAndChargeFacade.java:142)
de.fraunhofer.iao.sharedefleet.energiemanagement.services.EVSEHeartbeatEndpoint.requestChargingState(EVSEHeartbeatEndpoint.java:34)
sun.reflect.GeneratedMethodAccessor143.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:606)
org.springframework.ws.server.endpoint.MethodEndpoint.invoke(MethodEndpoint.java:134)
org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter.invokeInternal(DefaultMethodEndpointAdapter.java:240)
org.springframework.ws.server.endpoint.adapter.AbstractMethodEndpointAdapter.invoke(AbstractMethodEndpointAdapter.java:53)
org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:233)
org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:173)
org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:88)
org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:59)
org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:239)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:186)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
</pre></p><p><b>root cause</b> <pre>java.lang.ClassNotFoundException: org.springframework.dao.QueryTimeoutException.
所以我希望你能幫助我。
這就是我的主要
public class Main {
public static void main(String[] args)
{
boolean positive = true;
int counter = 0;
while (true)
{
if (counter >= 99)
{
positive = false;
}
if (counter <=-99)
{
positive = true;
}
if (positive == true)
{
counter ++;
}
else
{
counter --;
}
CloudCommunicator ccc = new CloudCommunicator("sh1");
EnergyManagerJob emj = ccc.SendRequest (true , true, 1 , 100 , "Nori2");
System.out.println("\nmax Current: " + emj.allowedMaximumCurrent);
System.out.println("charging status: " +emj.chargingPending);
System.out.println("power: " +emj.powerOn);
try
{
Thread.sleep(10000);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
} // end of while
}// end of main
您的'main'方法和web應用程序之間有什麼關係? –
聯繫遠程服務器的代碼在哪裏? – Carlo
添加'spring-mvc' lib至少 –