本文整理汇总了Java中org.springframework.web.bind.support.ConfigurableWebBindingInitializer.setConversionService方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurableWebBindingInitializer.setConversionService方法的具体用法?Java ConfigurableWebBindingInitializer.setConversionService怎么用?Java ConfigurableWebBindingInitializer.setConversionService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.bind.support.ConfigurableWebBindingInitializer
的用法示例。
在下文中一共展示了ConfigurableWebBindingInitializer.setConversionService方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; //导入方法依赖的package包/类
@Test
@Deprecated
public void test() throws Exception {
AnnotationMethodHandlerAdapter adapter = new AnnotationMethodHandlerAdapter();
ConfigurableWebBindingInitializer binder = new ConfigurableWebBindingInitializer();
GenericConversionService service = new DefaultConversionService();
service.addConverter(new ColorConverter());
binder.setConversionService(service);
adapter.setWebBindingInitializer(binder);
Spr7766Controller controller = new Spr7766Controller();
MockHttpServletRequest request = new MockHttpServletRequest();
request.setRequestURI("/colors");
request.setPathInfo("/colors");
request.addParameter("colors", "#ffffff,000000");
MockHttpServletResponse response = new MockHttpServletResponse();
adapter.handle(request, response, controller);
}
示例2: setUp
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
this.processor = new ServletModelAttributeMethodProcessor(false);
Method method = getClass().getDeclaredMethod("modelAttribute",
TestBean.class, TestBeanWithoutStringConstructor.class, Optional.class);
this.testBeanModelAttr = new MethodParameter(method, 0);
this.testBeanWithoutStringConstructorModelAttr = new MethodParameter(method, 1);
this.testBeanWithOptionalModelAttr = new MethodParameter(method, 2);
ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
initializer.setConversionService(new DefaultConversionService());
this.binderFactory = new ServletRequestDataBinderFactory(null, initializer);
this.mavContainer = new ModelAndViewContainer();
this.request = new MockHttpServletRequest();
this.webRequest = new ServletWebRequest(request);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:ServletModelAttributeMethodProcessorTests.java
示例3: resolveOptional
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; //导入方法依赖的package包/类
@Test
@SuppressWarnings("rawtypes")
public void resolveOptional() throws Exception {
ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
initializer.setConversionService(new DefaultConversionService());
WebDataBinderFactory binderFactory = new DefaultDataBinderFactory(initializer);
Object result = resolver.resolveArgument(paramOptional, null, webRequest, binderFactory);
assertEquals(Optional.class, result.getClass());
assertEquals(Optional.empty(), result);
this.request.addParameter("name", "123");
result = resolver.resolveArgument(paramOptional, null, webRequest, binderFactory);
assertEquals(Optional.class, result.getClass());
assertEquals(123, ((Optional) result).get());
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:RequestParamMethodArgumentResolverTests.java
示例4: setUp
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
this.processor = new ServletModelAttributeMethodProcessor(false);
Method method = getClass().getDeclaredMethod("modelAttribute",
TestBean.class, TestBeanWithoutStringConstructor.class);
this.testBeanModelAttr = new MethodParameter(method, 0);
this.testBeanWithoutStringConstructorModelAttr = new MethodParameter(method, 1);
ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
initializer.setConversionService(new DefaultConversionService());
this.binderFactory = new ServletRequestDataBinderFactory(null, initializer );
this.mavContainer = new ModelAndViewContainer();
this.request = new MockHttpServletRequest();
this.webRequest = new ServletWebRequest(request);
}
示例5: getConfigurableWebBindingInitializer
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; //导入方法依赖的package包/类
/**
* Return the {@link ConfigurableWebBindingInitializer} to use for
* initializing all {@link WebDataBinder} instances.
*/
protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer() {
ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
initializer.setConversionService(mvcConversionService());
initializer.setValidator(mvcValidator());
initializer.setMessageCodesResolver(getMessageCodesResolver());
return initializer;
}
示例6: setUp
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; //导入方法依赖的package包/类
@Before
public void setUp() {
ConfigurableWebBindingInitializer binder = new ConfigurableWebBindingInitializer();
GenericConversionService service = new DefaultConversionService();
service.addConverter(new Converter<String, NestedBean>() {
@Override
public NestedBean convert(String source) {
return new NestedBean(source);
}
});
binder.setConversionService(service);
adapter.setWebBindingInitializer(binder);
}