Package org.springframework.format.support

Examples of org.springframework.format.support.FormattingConversionService$PrinterConverter


   * controller methods and the {@code spring:eval} JSP tag.
   * Also see {@link #addFormatters} as an alternative to overriding this method.
   */
  @Bean
  public FormattingConversionService mvcConversionService() {
    FormattingConversionService conversionService = new DefaultFormattingConversionService();
    addFormatters(conversionService);
    return conversionService;
  }
View Full Code Here


   * controller methods and the {@code spring:eval} JSP tag.
   * Also see {@link #addFormatters} as an alternative to overriding this method.
   */
  @Bean
  public FormattingConversionService mvcConversionService() {
    FormattingConversionService conversionService = new DefaultFormattingConversionService();
    addFormatters(conversionService);
    return conversionService;
  }
View Full Code Here

    registry.addResourceHandler("/files/**").addResourceLocations("files/");
  }
 
  @Override
  public FormattingConversionService mvcConversionService() {
    FormattingConversionService formattingConversionService = super.mvcConversionService();
    if(env.getProperty("input.trimToNull", Boolean.class, Boolean.TRUE)){
      formattingConversionService.addConverter(new Converter<String, String>() {
        public String convert(String source) { return StringUtils.trimToNull(source); }});
    }
   
    return formattingConversionService;
  }
View Full Code Here

*/
public class ServletRequestContextBuilderTest {

    @Test
    public void testIpParsed() {
        FormattingConversionService conversionService = mock(FormattingConversionService.class);
        SessionManager sessionManager = mock(SessionManager.class);
        ServletRequestContextBuilder requestContextBuilder = new ServletRequestContextBuilder(conversionService);
        RopContext ropContext = mock(RopContext.class);

        //构造HttpServletRequest
View Full Code Here

     *
     * @throws Exception
     */
    @Test
    public void testBuildBySysParams1() throws Exception {
        FormattingConversionService conversionService = mock(FormattingConversionService.class);
        SessionManager sessionManager = mock(SessionManager.class);
        ServletRequestContextBuilder requestContextBuilder = new ServletRequestContextBuilder(conversionService);

        RopContext ropContext = mock(RopContext.class);
        ServiceMethodHandler methodHandler = mock(ServiceMethodHandler.class);
View Full Code Here

     *
     * @throws Exception
     */
    @Test
    public void testBuildBySysParams2() throws Exception {
        FormattingConversionService conversionService = mock(FormattingConversionService.class);
        SessionManager sessionManager = mock(SessionManager.class);
        ServletRequestContextBuilder requestContextBuilder = new ServletRequestContextBuilder(conversionService);
        RopContext ropContext = mock(RopContext.class);


View Full Code Here

     *
     * @throws Exception
     */
    @Test(expectedExceptions = {IllegalArgumentException.class})
    public void testBuildBySysParams3() throws Exception {
        FormattingConversionService conversionService = mock(FormattingConversionService.class);
        ServletRequestContextBuilder requestContextBuilder = new ServletRequestContextBuilder(conversionService);

        RopContext ropContext = mock(RopContext.class);
        ServiceMethodHandler methodHandler = mock(ServiceMethodHandler.class);
        when(ropContext.getServiceMethodHandler("method1", "3.0")).thenReturn(methodHandler);
View Full Code Here

  }

  public void testBindingWithFormatterAgainstList() {
    BeanWithIntegerList tb = new BeanWithIntegerList();
    DataBinder binder = new DataBinder(tb);
    FormattingConversionService conversionService = new FormattingConversionService();
    DefaultConversionService.addDefaultConverters(conversionService);
    conversionService.addFormatterForFieldType(Float.class, new NumberFormatter());
    binder.setConversionService(conversionService);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("integerList[0]", "1");

    LocaleContextHolder.setLocale(Locale.GERMAN);
View Full Code Here

  }

  public void testBindingErrorWithFormatterAgainstList() {
    BeanWithIntegerList tb = new BeanWithIntegerList();
    DataBinder binder = new DataBinder(tb);
    FormattingConversionService conversionService = new FormattingConversionService();
    DefaultConversionService.addDefaultConverters(conversionService);
    conversionService.addFormatterForFieldType(Float.class, new NumberFormatter());
    binder.setConversionService(conversionService);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("integerList[0]", "1x2");

    LocaleContextHolder.setLocale(Locale.GERMAN);
View Full Code Here

  }

  public void testBindingWithFormatterAgainstFields() {
    TestBean tb = new TestBean();
    DataBinder binder = new DataBinder(tb);
    FormattingConversionService conversionService = new FormattingConversionService();
    DefaultConversionService.addDefaultConverters(conversionService);
    conversionService.addFormatterForFieldType(Float.class, new NumberFormatter());
    binder.setConversionService(conversionService);
    binder.initDirectFieldAccess();
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("myFloat", "1,2");
View Full Code Here

TOP

Related Classes of org.springframework.format.support.FormattingConversionService$PrinterConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.