NutzCN Logo
问答 forum表单用post时,接口接不到数据,而用get时可以接收到数据,是什么情况?
发布于 2774天前 作者 shusheng 2137 次浏览 复制 上一个帖子 下一个帖子
标签:
<form id="loginForm" action="${base!}/platform/login/doLogin" data-parsley-validate="" novalidate=""
                              role="form"
                              method="post">
                            <input type="hidden" id="captcha" name="captcha">
protected AuthenticationToken createToken(HttpServletRequest request) {
        String username = getUsername(request);
        String password = getPassword(request);
        String captcha = getCaptcha(request);
        boolean rememberMe = isRememberMe(request);
        String host = getHost(request);
        return new CaptchaToken(username, password, rememberMe, host, captcha);
    }

在用post时,过滤器中也接收不到数据,是用getParameter方法的,用get时可以正常接收数据

10 回复

什么过滤器?

public class PlatformAuthenticationFilter extends FormAuthenticationFilter implements ActionFilter {

    private String captchaParam = "platformCaptcha";

    public String getCaptchaParam() {
        return captchaParam;
    }

    protected String getCaptcha(ServletRequest request) {
        return WebUtils.getCleanParam(request, getCaptchaParam());
    }

    protected AuthenticationToken createToken(HttpServletRequest request) {
        String username = getUsername(request);
        String password = getPassword(request);
        String captcha = getCaptcha(request);
        boolean rememberMe = isRememberMe(request);
        String host = getHost(request);
        return new CaptchaToken(username, password, rememberMe, host, captcha);
    }

@wendal 登陆的过滤器

走的是ajax吗?

<form id="loginForm" action="${base!}/platform/login/doLogin" data-parsley-validate="" novalidate=""
                              role="form"
                              method="get">
                            <input type="hidden" id="captcha" name="captcha">

                            <div class="form-group">
                                <input type="text" id="username" name="username" value="superadmin" required
                                       class="form-control input-lg mb25"
                                       placeholder="${msg['login.username']}">
                            </div>
                            <div class="form-group">
                                <input type="password" id="password" name="password" value="123456" required
                                       class="form-control input-lg mb25"
                                       placeholder="${msg['login.password']}">
                            </div>
                            <p id="tip" class="bg-danger p15" style="display:none"></p>

                            <div class="show">
                                <button class="btn btn-primary btn-lg btn-block" type="submit"
                                        data-loading-text="${msg['login.submit']}...">
                                    ${msg['login.submit']}
                                </button>
                            </div>
                        </form>

beetl中的form表单
@wendal

改成了get后就能收到数据了

看看发送的content type

Content-Type:application/json;charset=UTF-8

怎么是json呢?? 一般发ajax才会主动设置为json的

这是nutzshop里面的登陆代码
@wendal

肯定走ajax了

添加回复
请先登陆
回到顶部