我和春天MVC应用程序一起制定一个比特币钱包和我有控制的定义,春天如何在我收到交易时刷新页面?
@RequestMapping(value = "/")
public String showBitcoinWallet() {
return "index";
}
这将返回index.jsp
页面提供有关的相关信息,
直到此刻应用程序未同步到区块链,它将在每3000毫秒从脚本中刷新,
<html>
<body>
<!- some code ->
<!- some code ->
</body>
<script>
<% if(!model.isSyncFinished()) {%>
setTimeout(function() {
window.location.reload(1);
}, 3000);
<% }%>
</script>
</html>
对于发送操作,弹出窗口打开并且用户执行提交。此操作刷新页面并更新信息(例如余额,地址等)。在接收实例中,页面不刷新,只有在手动刷新时才更新。
I need to refresh the page after the user received the money.
我有返回接收执行操作的boolean
的方法,
public static boolean isMoneyReceived() {
try {
WalletMain.bitcoin.wallet().addEventListener(new AbstractWalletEventListener() {
@Override
public void onCoinsReceived(Wallet w, Transaction tx, Coin prevBalance, Coin newBalance) {
// Runs in the dedicated "user thread".
//
// The transaction "tx" can either be pending, or included into a block (we didn't see the broadcast).
Coin value = tx.getValueSentToMe(w);
// System.out.println("Received tx for " + value.toFriendlyString() + ": " + tx);
// System.out.println("Transaction will be forwarded after it confirms.");
}
});
return true;
} catch (Exception e) {
e.printStackTrace();
} finally {
return false;
}
}
所以,内涵会写代码中<script>
,如果isMoneyReceived
回报true
,然后,我将需要刷新页面。在这种情况下,我可能需要将方法放入iteration
,例如while
,并继续使用if
条件调用。
可能有第二个选项完成controller
。我试图做到这一点在<script>
标签没有成功里面index.jsp
页面,
我最终得到了错误,
HTTP Status [500] – [Internal Server Error]
Type Exception Report
Message java.lang.ClassNotFoundException: org.apache.jsp.WEB_002dINF.jsps.index_jsp
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.WEB_002dINF.jsps.index_jsp
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:176)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:380)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
如何解决这个问题?如前所述,如果我可以从Spring controller
重定向页面,那也可以。
我不用'Javascript/Ajax'编写很多程序。在完成实施后,我会接受你的回答。 – Arefe