spring mvc - How to post data and redirect to another page using GWT? -
when press button post data server , there redirect page. used requestbuilder waiting response, , of course it. , nothing happens, same page stays. see requestbuidler shouldn't used here... should use post data , able redirect?
in spring
@requestmapping(method=requestmethod.post, value="/ddd") public modelandview processorder(@requestbody string orderinstring, httpsession session) throws exception{ ... return new modelandview(new redirectview("abc")); }
in gwt
public void postdata(final string data, final string url) { requestbuilder builder = new requestbuilder(requestbuilder.post, url); try { builder.sendrequest(data, new requestcallback() { public void onerror(request request, throwable exception) { ... } public void onresponsereceived(request request, response response) { if (200 == response.getstatuscode()) { .. } else { .. } } }); } catch (requestexception e) { ... } return; }
formpanel form = new formpanel("_self"); form.setmethod(formpanel.method_get); hidden params0 = new hidden("param1", "value1"); hidden params1 = new hidden("param1", "value2"); hidden params2 = new hidden("param2", "value3"); flowpanel panel = new flowpanel(); panel.add(params0); panel.add(params1); panel.add(params2); form.add(panel); form.setaction(gwt.getmodulebaseurl() + "../myservlet"); rootpanel.get().add(form); form.submit();
thats it. code adds formpanel , sends form.
Comments
Post a Comment