Polishing
This commit is contained in:
@@ -256,7 +256,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||
Class<?> targetBeanClass = targetBean.getClass();
|
||||
if (!methodDeclaringClass.isAssignableFrom(targetBeanClass)) {
|
||||
String msg = "The mapped controller method class '" + methodDeclaringClass.getName() +
|
||||
"' is not an instance of the actual controller bean instance '" +
|
||||
"' is not an instance of the actual controller bean class '" +
|
||||
targetBeanClass.getName() + "'. If the controller requires proxying " +
|
||||
"(e.g. due to @Transactional), please use class-based proxying.";
|
||||
throw new IllegalStateException(getInvocationErrorMessage(msg, args));
|
||||
@@ -266,7 +266,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||
private String getInvocationErrorMessage(String message, Object[] resolvedArgs) {
|
||||
StringBuilder sb = new StringBuilder(getDetailedErrorMessage(message));
|
||||
sb.append("Resolved arguments: \n");
|
||||
for (int i=0; i < resolvedArgs.length; i++) {
|
||||
for (int i = 0; i < resolvedArgs.length; i++) {
|
||||
sb.append("[").append(i).append("] ");
|
||||
if (resolvedArgs[i] == null) {
|
||||
sb.append("[null] \n");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -172,7 +172,7 @@ public class ModelAttributeMethodProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resovleArgumentValidation() throws Exception {
|
||||
public void resolveArgumentValidation() throws Exception {
|
||||
String name = "attrName";
|
||||
Object target = new TestBean();
|
||||
mavContainer.addAttribute(name, target);
|
||||
@@ -187,7 +187,7 @@ public class ModelAttributeMethodProcessorTests {
|
||||
assertTrue(dataBinder.isValidateInvoked());
|
||||
}
|
||||
|
||||
@Test(expected=BindException.class)
|
||||
@Test(expected = BindException.class)
|
||||
public void resovleArgumentBindException() throws Exception {
|
||||
String name = "testBean";
|
||||
Object target = new TestBean();
|
||||
@@ -203,9 +203,7 @@ public class ModelAttributeMethodProcessorTests {
|
||||
verify(binderFactory).createBinder(webRequest, target, name);
|
||||
}
|
||||
|
||||
// SPR-9378
|
||||
|
||||
@Test
|
||||
@Test // SPR-9378
|
||||
public void resolveArgumentOrdering() throws Exception {
|
||||
String name = "testBean";
|
||||
Object testBean = new TestBean(name);
|
||||
@@ -241,6 +239,7 @@ public class ModelAttributeMethodProcessorTests {
|
||||
assertSame(testBean, mavContainer.getModel().get("testBean"));
|
||||
}
|
||||
|
||||
|
||||
private static class StubRequestDataBinder extends WebRequestDataBinder {
|
||||
|
||||
private boolean bindInvoked;
|
||||
@@ -273,31 +272,31 @@ public class ModelAttributeMethodProcessorTests {
|
||||
public void validate(Object... validationHints) {
|
||||
validateInvoked = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Target({ METHOD, FIELD, CONSTRUCTOR, PARAMETER })
|
||||
|
||||
@Target({METHOD, FIELD, CONSTRUCTOR, PARAMETER})
|
||||
@Retention(RUNTIME)
|
||||
public @interface Valid {
|
||||
}
|
||||
|
||||
|
||||
@SessionAttributes(types=TestBean.class)
|
||||
private static class ModelAttributeHandler {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void modelAttribute(@ModelAttribute("attrName") @Valid TestBean annotatedAttr,
|
||||
Errors errors,
|
||||
int intArg,
|
||||
@ModelAttribute TestBean defaultNameAttr,
|
||||
TestBean notAnnotatedAttr) {
|
||||
public void modelAttribute(@ModelAttribute("attrName") @Valid TestBean annotatedAttr, Errors errors,
|
||||
int intArg, @ModelAttribute TestBean defaultNameAttr, TestBean notAnnotatedAttr) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ModelAttribute("modelAttrName")
|
||||
private String annotatedReturnValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private TestBean notAnnotatedReturnValue() {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user