首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GWT和SpringSecurity

GWT和SpringSecurity
EN

Stack Overflow用户
提问于 2011-02-09 12:02:51
回答 2查看 2.6K关注 0票数 2

我创建了两个模块

  1. GWTAppAuth
  2. GWTApp

当我尝试将表单从GWTAppAuth发送到j_spring_security_check时,什么都没有发生。

Firebug显示在控制台中

代码语言:javascript
复制
"Failed to load source for:http://127.0.0.1:8888/j_spring_security_check"

但是如果我在此之后尝试手动访问GWTApp,它就能工作了。有人知道怎么回事吗?

看起来Security不会重定向到第二个(GWTApp)。

我该怎么查?

在托管模式下运行应用程序尝试访问GWTApp.html

  • Spring安全性,将我重定向到GWTAppAuth.html

  • Press登录按钮

在这个地方,如果我们检查一下萤火虫日志,我们可以看到

代码语言:javascript
复制
"POST //127.0.0.1:8888/j_spring_security_check"

以及回应-

代码语言:javascript
复制
"Failed to load source for: http://127.0.0.1:8888/j_spring_security_check"

然后下一个记录-

代码语言:javascript
复制
"GET //127.0.0.1:8888/GWT/GWTApp.html?gwt.codesvr=127.0.0.1:9997"

获取所有需要的资源

现在我可以手动输入

代码语言:javascript
复制
"//127.0.0.1:8888/GWT/GWTApp.html" 

现在我可以访问GWTApp.html了

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-10-27 12:05:44

我找到了解决办法。

例如,您应该使用html表单并提交按钮,而不是GWT提供的小部件:

代码语言:javascript
复制
<form action="/j_spring_security_check" method="post">
   <g:Label>
       login
   </g:Label>
   <g:TextBox name="j_username" width="200" />
       <g:Label>
           password
       </g:Label>
       <g:PasswordTextBox name="j_password" width="200" />
       <input name="submit" type="submit" value="Login" />
</form>

或者捕捉表单提交完成的事件,以防您使用GWT FormPanel小部件:

代码语言:javascript
复制
public class LoginFormB extends Composite {

  private static LoginFormBUiBinder uiBinder = GWT.create(LoginFormBUiBinder.class);

  interface LoginFormBUiBinder extends UiBinder<Widget, LoginFormB> {}

  @UiField
  FormPanel formPanel;

  public LoginFormB() {
    formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() {

        @Override
        public void onSubmitComplete(SubmitCompleteEvent arg0) {
            // Redirect to needed page
            redirect("needed url");
        }
    });
    initWidget(uiBinder.createAndBindUi(this));
  }

  public static native void redirect(String url)/*-{
    $wnd.location = url;
  }-*/;
}
票数 4
EN

Stack Overflow用户

发布于 2011-02-23 11:39:19

我认为您不能在同一个应用程序中直接集成Security和GWT。你需要一些中间的东西来粘合它们。

试着检查这些教程:http://krams915.blogspot.com/2011/01/spring-and-gwt-integration-using-maven.html

http://krams915.blogspot.com/2011/01/spring-and-gwt-security-via-spring.html

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4944588

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档