当我按下按钮时,我将一些数据发布到服务器,然后重定向到另一个页面。 我使用了RequestBuilder,但它正在等待响应,当然得到它。没有任何反应,同一页留下来。我看到不应该在这里使用RequestBuidler ...我应该使用什么来发布数据并能够重定向?
在春天
@RequestMapping(method=RequestMethod.POST, value="/ddd")
public ModelAndView processOrder(@RequestBody String orderInString, HttpSession session) throws Exception{
...
return new ModelAndView(new RedirectView("abc"));
}
在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;
}
答案 0 :(得分:4)
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();
多数民众赞成。代码添加FormPanel并发送表单。
答案 1 :(得分:0)
添加更多规格,代码,这很模糊。 既然你使用的是Spring-mvc,你应该有类似的东西
private static final String newPage = "index2"; //this is resolved with view resolver
@RequestMapping(params = "action=button")
protected String getALPLicense(final RenderRequest request,
final RenderResponse response, final Model model) throws Exception {
try{
}catch{
}
return newPage; //this is your new redirected page
}