Recently do spring development, personally think, controller and client JS communication when the parameter class passed only a certain number of methods, in order to reduce the impact on other functions, to define the parameter class as the Controller class
Nested classes (inner classes). But practice finds No.
The system will error:
Servlet.service () for Servlets [Kingkoo] in the context with path [] threw exception [Request processing failed; nested Excepti On are org.springframework.beans.BeanInstantiationException:Failed to instantiate [ Com.itl.wms.mvc.systemsetting.poqcsettingcontroller$queryparameter]: No default constructor found; Nested exception is java.lang.NoSuchMethodException: ***************controller$ nested class .<init> ()] With Root cause
Java.lang.NoSuchMethodException:com.itl.wms.mvc.systemsetting. controller$ Nested class .<init> ()
Tip the nested class does not have a constructor for empty arguments. Although I have defined an empty constructor for a class.
Because spring looks for a constructor for a parameter type, it indicates the constructor to find an empty argument:
Return Instantiateclass (Clazz.getdeclaredconstructor ()); Org.springframework.beans.BeanUtils.instantiateClass (beanutils.java:104)
However, inside Java, a nested class is a constructor that has no empty arguments:
public class App {
Public class Nest
{
Public Nest () {}
}
public static void Main (string[] args) throws Exception {
Nestclassconstrunct ();
}
Private static void Nestclassconstrunct ()
{
Java.lang.Class c= Nest.class;
Constructor<?>[] cc= c.getconstructors ();
Parameter[] p;
for (int i = 0; i < cc.length; i++) {
System.out.println (Cc[i].tostring ());
P=cc[i].getparameters ();
for (int j = 0; J < P.length; J + +) {
System.out.println (P[j].getname () + ":" +p[j].getparameterizedtype (). toString ());
}
}
}
Output:
Public App$nest (APP)
Arg0:class App
So, you can only move the parameter class into a specified package.
Please correct the master.
The parameters of the Controller method in spring note 1:MVN cannot be nested classes (inner classes).