org.springframework.web.multipart.support.StringMultipartFileEditor Java Examples

The following examples show how to use org.springframework.web.multipart.support.StringMultipartFileEditor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebRequestDataBinderTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testMultipartFileAsString() {
	TestBean target = new TestBean();
	WebRequestDataBinder binder = new WebRequestDataBinder(target);
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());

	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	request.addFile(new MockMultipartFile("name", "Juergen".getBytes()));
	binder.bind(new ServletWebRequest(request));
	assertEquals("Juergen", target.getName());
}
 
Example #2
Source File: WebRequestDataBinderTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testMultipartFileAsStringArray() {
	TestBean target = new TestBean();
	WebRequestDataBinder binder = new WebRequestDataBinder(target);
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());

	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	request.addFile(new MockMultipartFile("stringArray", "Juergen".getBytes()));
	binder.bind(new ServletWebRequest(request));
	assertEquals(1, target.getStringArray().length);
	assertEquals("Juergen", target.getStringArray()[0]);
}
 
Example #3
Source File: WebRequestDataBinderTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testMultipartFilesAsStringArray() {
	TestBean target = new TestBean();
	WebRequestDataBinder binder = new WebRequestDataBinder(target);
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());

	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	request.addFile(new MockMultipartFile("stringArray", "Juergen".getBytes()));
	request.addFile(new MockMultipartFile("stringArray", "Eva".getBytes()));
	binder.bind(new ServletWebRequest(request));
	assertEquals(2, target.getStringArray().length);
	assertEquals("Juergen", target.getStringArray()[0]);
	assertEquals("Eva", target.getStringArray()[1]);
}
 
Example #4
Source File: WebRequestDataBinderTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testMultipartFileAsString() {
	TestBean target = new TestBean();
	WebRequestDataBinder binder = new WebRequestDataBinder(target);
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());

	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	request.addFile(new MockMultipartFile("name", "Juergen".getBytes()));
	binder.bind(new ServletWebRequest(request));
	assertEquals("Juergen", target.getName());
}
 
Example #5
Source File: WebRequestDataBinderTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testMultipartFileAsStringArray() {
	TestBean target = new TestBean();
	WebRequestDataBinder binder = new WebRequestDataBinder(target);
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());

	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	request.addFile(new MockMultipartFile("stringArray", "Juergen".getBytes()));
	binder.bind(new ServletWebRequest(request));
	assertEquals(1, target.getStringArray().length);
	assertEquals("Juergen", target.getStringArray()[0]);
}
 
Example #6
Source File: WebRequestDataBinderTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testMultipartFilesAsStringArray() {
	TestBean target = new TestBean();
	WebRequestDataBinder binder = new WebRequestDataBinder(target);
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());

	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	request.addFile(new MockMultipartFile("stringArray", "Juergen".getBytes()));
	request.addFile(new MockMultipartFile("stringArray", "Eva".getBytes()));
	binder.bind(new ServletWebRequest(request));
	assertEquals(2, target.getStringArray().length);
	assertEquals("Juergen", target.getStringArray()[0]);
	assertEquals("Eva", target.getStringArray()[1]);
}
 
Example #7
Source File: WebRequestDataBinderTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultipartFileAsString() {
	TestBean target = new TestBean();
	WebRequestDataBinder binder = new WebRequestDataBinder(target);
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());

	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	request.addFile(new MockMultipartFile("name", "Juergen".getBytes()));
	binder.bind(new ServletWebRequest(request));
	assertEquals("Juergen", target.getName());
}
 
Example #8
Source File: WebRequestDataBinderTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultipartFileAsStringArray() {
	TestBean target = new TestBean();
	WebRequestDataBinder binder = new WebRequestDataBinder(target);
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());

	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	request.addFile(new MockMultipartFile("stringArray", "Juergen".getBytes()));
	binder.bind(new ServletWebRequest(request));
	assertEquals(1, target.getStringArray().length);
	assertEquals("Juergen", target.getStringArray()[0]);
}
 
Example #9
Source File: WebRequestDataBinderTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultipartFilesAsStringArray() {
	TestBean target = new TestBean();
	WebRequestDataBinder binder = new WebRequestDataBinder(target);
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());

	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	request.addFile(new MockMultipartFile("stringArray", "Juergen".getBytes()));
	request.addFile(new MockMultipartFile("stringArray", "Eva".getBytes()));
	binder.bind(new ServletWebRequest(request));
	assertEquals(2, target.getStringArray().length);
	assertEquals("Juergen", target.getStringArray()[0]);
	assertEquals("Eva", target.getStringArray()[1]);
}
 
Example #10
Source File: GrailsDataBinder.java    From AlgoTrader with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Utility method for creating a GrailsDataBinder instance
 *
 * @param target The target object to bind to
 * @param objectName The name of the object
 * @return A GrailsDataBinder instance
 */
public static GrailsDataBinder createBinder(Object target, String objectName) {
	GrailsDataBinder binder = new GrailsDataBinder(target, objectName);
	binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());
	binder.registerCustomEditor(Currency.class, new CurrencyEditor());
	binder.registerCustomEditor(Locale.class, new LocaleEditor());
	binder.registerCustomEditor(TimeZone.class, new TimeZoneEditor());
	binder.registerCustomEditor(URI.class, new UriEditor());

	registerCustomEditors(binder);

	return binder;
}
 
Example #11
Source File: ServletAnnotationControllerHandlerMethodTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@InitBinder
public void initBinder(WebDataBinder binder) {
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());
}
 
Example #12
Source File: ServletAnnotationControllerHandlerMethodTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@InitBinder
public void initBinder(WebDataBinder binder) {
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());
}
 
Example #13
Source File: ServletAnnotationControllerTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@InitBinder
public void initBinder(WebDataBinder binder) {
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());
}
 
Example #14
Source File: ServletAnnotationControllerHandlerMethodTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@InitBinder
public void initBinder(WebDataBinder binder) {
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());
}