Java 类org.springframework.web.bind.support.WebRequestDataBinder 实例源码

项目:springboot-shiro-cas-mybatis    文件:TicketResource.java   
/**
 * Obtain credentials from the request.
 *
 * @return the credential
 */
protected Credential obtainCredentials() {
    final UsernamePasswordCredential c = new UsernamePasswordCredential();
    final WebRequestDataBinder binder = new WebRequestDataBinder(c);
    final RestletWebRequest webRequest = new RestletWebRequest(getRequest());

    final Form form = new Form(getRequest().getEntity());
    logFormRequest(form);

    if (!form.isEmpty()) {
        binder.bind(webRequest);
        return c;
    }
    LOGGER.trace("Failed to bind the request to credentials. Resulting form is empty");
    return null;
}
项目:cas4.1.9    文件:TicketResource.java   
/**
 * Obtain credentials from the request.
 *
 * @return the credential
 */
protected Credential obtainCredentials() {
    final UsernamePasswordCredential c = new UsernamePasswordCredential();
    final WebRequestDataBinder binder = new WebRequestDataBinder(c);
    final RestletWebRequest webRequest = new RestletWebRequest(getRequest());

    final Form form = new Form(getRequest().getEntity());
    logFormRequest(form);

    if (!form.isEmpty()) {
        binder.bind(webRequest);
        return c;
    }
    LOGGER.trace("Failed to bind the request to credentials. Resulting form is empty");
    return null;
}
项目:cas4.0.x-server-wechat    文件:TicketResource.java   
protected Credential obtainCredentials() {
    final UsernamePasswordCredential c = new UsernamePasswordCredential();
    final WebRequestDataBinder binder = new WebRequestDataBinder(c);
    final RestletWebRequest webRequest = new RestletWebRequest(getRequest());

    logFormRequest(new Form(getRequest().getEntity()));
    binder.bind(webRequest);

    return c;
}
项目:spring4-understanding    文件:ModelAttributeMethodProcessorTests.java   
private void getAttributeFromModel(String expectedAttributeName, MethodParameter param) throws Exception {
    Object target = new TestBean();
    mavContainer.addAttribute(expectedAttributeName, target);

    WebDataBinder dataBinder = new WebRequestDataBinder(target);
    WebDataBinderFactory factory = mock(WebDataBinderFactory.class);
    given(factory.createBinder(webRequest, target, expectedAttributeName)).willReturn(dataBinder);

    processor.resolveArgument(param, mavContainer, webRequest, factory);
    verify(factory).createBinder(webRequest, target, expectedAttributeName);
}
项目:spring4-understanding    文件:ModelAttributeMethodProcessorTests.java   
@Test
public void resovleArgumentViaDefaultConstructor() throws Exception {
    WebDataBinder dataBinder = new WebRequestDataBinder(null);

    WebDataBinderFactory factory = mock(WebDataBinderFactory.class);
    given(factory.createBinder((NativeWebRequest) anyObject(), notNull(), eq("attrName"))).willReturn(dataBinder);

    processor.resolveArgument(paramNamedValidModelAttr, mavContainer, webRequest, factory);

    verify(factory).createBinder((NativeWebRequest) anyObject(), notNull(), eq("attrName"));
}
项目:cas-4.0.1    文件:TicketResource.java   
protected Credential obtainCredentials() {
    final UsernamePasswordCredential c = new UsernamePasswordCredential();
    final WebRequestDataBinder binder = new WebRequestDataBinder(c);
    final RestletWebRequest webRequest = new RestletWebRequest(getRequest());

    logFormRequest(new Form(getRequest().getEntity()));
    binder.bind(webRequest);

    return c;
}
项目:p00    文件:TicketResource.java   
protected Credential obtainCredentials() {
    final UsernamePasswordCredential c = new UsernamePasswordCredential();
    final WebRequestDataBinder binder = new WebRequestDataBinder(c);
    final RestletWebRequest webRequest = new RestletWebRequest(getRequest());

    logFormRequest(new Form(getRequest().getEntity()));
    binder.bind(webRequest);

    return c;
}
项目:cas-server-4.0.1    文件:TicketResource.java   
protected Credential obtainCredentials() {
    final UsernamePasswordCredential c = new UsernamePasswordCredential();
    final WebRequestDataBinder binder = new WebRequestDataBinder(c);
    final RestletWebRequest webRequest = new RestletWebRequest(getRequest());

    logFormRequest(new Form(getRequest().getEntity()));
    binder.bind(webRequest);

    return c;
}
项目:class-guard    文件:ModelAttributeMethodProcessorTests.java   
private void getAttributeFromModel(String expectedAttributeName, MethodParameter param) throws Exception {
    Object target = new TestBean();
    mavContainer.addAttribute(expectedAttributeName, target);

    WebDataBinder dataBinder = new WebRequestDataBinder(target);
    WebDataBinderFactory factory = mock(WebDataBinderFactory.class);
    given(factory.createBinder(webRequest, target, expectedAttributeName)).willReturn(dataBinder);

    processor.resolveArgument(param, mavContainer, webRequest, factory);
    verify(factory).createBinder(webRequest, target, expectedAttributeName);
}
项目:class-guard    文件:ModelAttributeMethodProcessorTests.java   
@Test
public void resovleArgumentViaDefaultConstructor() throws Exception {
    WebDataBinder dataBinder = new WebRequestDataBinder(null);

    WebDataBinderFactory factory = mock(WebDataBinderFactory.class);
    given(factory.createBinder((NativeWebRequest) anyObject(), notNull(), eq("attrName"))).willReturn(dataBinder);

    processor.resolveArgument(paramNamedValidModelAttr, mavContainer, webRequest, factory);

    verify(factory).createBinder((NativeWebRequest) anyObject(), notNull(), eq("attrName"));
}
项目:lams    文件:HandlerMethodInvoker.java   
protected WebDataBinder createBinder(NativeWebRequest webRequest, Object target, String objectName)
        throws Exception {

    return new WebRequestDataBinder(target, objectName);
}
项目:lams    文件:HandlerMethodInvoker.java   
protected void doBind(WebDataBinder binder, NativeWebRequest webRequest) throws Exception {
    ((WebRequestDataBinder) binder).bind(webRequest);
}
项目:spring4-understanding    文件:HandlerMethodInvoker.java   
protected WebDataBinder createBinder(NativeWebRequest webRequest, Object target, String objectName)
        throws Exception {

    return new WebRequestDataBinder(target, objectName);
}
项目:spring4-understanding    文件:HandlerMethodInvoker.java   
protected void doBind(WebDataBinder binder, NativeWebRequest webRequest) throws Exception {
    ((WebRequestDataBinder) binder).bind(webRequest);
}
项目:class-guard    文件:HandlerMethodInvoker.java   
protected WebDataBinder createBinder(NativeWebRequest webRequest, Object target, String objectName)
        throws Exception {

    return new WebRequestDataBinder(target, objectName);
}
项目:class-guard    文件:HandlerMethodInvoker.java   
protected void doBind(WebDataBinder binder, NativeWebRequest webRequest) throws Exception {
    ((WebRequestDataBinder) binder).bind(webRequest);
}
项目:spring4-understanding    文件:RequestParamMethodArgumentResolverTests.java   
@Test
public void missingRequestParamEmptyValueConvertedToNull() throws Exception {

    WebDataBinder binder = new WebRequestDataBinder(null);
    binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));

    WebDataBinderFactory binderFactory = mock(WebDataBinderFactory.class);
    given(binderFactory.createBinder(webRequest, null, "stringNotAnnot")).willReturn(binder);

    this.request.addParameter("stringNotAnnot", "");

    Object arg = resolver.resolveArgument(paramStringNotAnnot, null, webRequest, binderFactory);

    assertNull(arg);
}
项目:spring4-understanding    文件:RequestParamMethodArgumentResolverTests.java   
@Test
public void missingRequestParamEmptyValueNotRequired() throws Exception {

    WebDataBinder binder = new WebRequestDataBinder(null);
    binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));

    WebDataBinderFactory binderFactory = mock(WebDataBinderFactory.class);
    given(binderFactory.createBinder(webRequest, null, "name")).willReturn(binder);

    this.request.addParameter("name", "");

    Object arg = resolver.resolveArgument(paramNotRequired, null, webRequest, binderFactory);

    assertNull(arg);
}
项目:class-guard    文件:RequestParamMethodArgumentResolverTests.java   
@Test
public void missingRequestParamEmptyValueConvertedToNull() throws Exception {

    WebDataBinder binder = new WebRequestDataBinder(null);
    binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));

    WebDataBinderFactory binderFactory = mock(WebDataBinderFactory.class);
    given(binderFactory.createBinder(webRequest, null, "stringNotAnnot")).willReturn(binder);

    this.request.addParameter("stringNotAnnot", "");

    Object arg = resolver.resolveArgument(paramStringNotAnnot, null, webRequest, binderFactory);

    assertNull(arg);
}
项目:class-guard    文件:RequestParamMethodArgumentResolverTests.java   
@Test
public void missingRequestParamEmptyValueNotRequired() throws Exception {

    WebDataBinder binder = new WebRequestDataBinder(null);
    binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));

    WebDataBinderFactory binderFactory = mock(WebDataBinderFactory.class);
    given(binderFactory.createBinder(webRequest, null, "name")).willReturn(binder);

    this.request.addParameter("name", "");

    Object arg = resolver.resolveArgument(paramNotRequired, null, webRequest, binderFactory);

    assertNull(arg);
}
项目:lams    文件:ModelAttributeMethodProcessor.java   
/**
 * Extension point to bind the request to the target object.
 * @param binder the data binder instance to use for the binding
 * @param request the current request
 */
protected void bindRequestParameters(WebDataBinder binder, NativeWebRequest request) {
    ((WebRequestDataBinder) binder).bind(request);
}
项目:spring4-understanding    文件:ModelAttributeMethodProcessor.java   
/**
 * Extension point to bind the request to the target object.
 * @param binder the data binder instance to use for the binding
 * @param request the current request
 */
protected void bindRequestParameters(WebDataBinder binder, NativeWebRequest request) {
    ((WebRequestDataBinder) binder).bind(request);
}
项目:class-guard    文件:ModelAttributeMethodProcessor.java   
/**
 * Extension point to bind the request to the target object.
 * @param binder the data binder instance to use for the binding
 * @param request the current request
 */
protected void bindRequestParameters(WebDataBinder binder, NativeWebRequest request) {
    ((WebRequestDataBinder) binder).bind(request);
}