Model:
PackageOrg.springframework.ui;Importjava.util.Collection;ImportJava.util.Map; Public InterfaceModel {model AddAttribute (String attributename, Object AttributeValue); Model AddAttribute (Object attributevalue); Model addallattributes (Collection<?>attributevalues); Model addallattributes (Map<string,?>attributes); Model mergeattributes (Map<string,?>attributes); BooleanContainsattribute (String attributename); Map<string, object>Asmap ();}
MAP:
PackageJava.util; Public InterfaceMap<k,v> { intsize (); BooleanIsEmpty (); BooleanContainsKey (Object key); BooleanContainsvalue (Object value); V get (Object key); V Put (K key, v value); V Remove (Object key); voidPutall (map<?extendsK?extendsV>m); voidClear (); Set<K>KeySet (); Collection<V>values (); Set<map.entry<k, v>>EntrySet (); InterfaceEntry<k,v>{K getKey (); V GetValue (); V SetValue (v value); Booleanequals (Object O); inthashcode (); } //Comparison and hashing Booleanequals (Object O); inthashcode ();}
Modelmap:
PackageOrg.springframework.ui;Importjava.util.Collection;ImportJava.util.LinkedHashMap;ImportJava.util.Map;Importorg.springframework.core.Conventions;ImportOrg.springframework.util.Assert; @SuppressWarnings ("Serial") Public classModelmapextendsLinkedhashmap<string, object> { PublicModelmap () {} PublicModelmap (String attributename, Object attributevalue) {AddAttribute (AttributeName, AttributeValue); } PublicModelmap (Object attributevalue) {AddAttribute (AttributeValue); } Publicmodelmap AddAttribute (String attributename, Object attributevalue) {assert.notnull (AttributeName,"Model attribute name must not being null"); Put (AttributeName, AttributeValue); return This; } Publicmodelmap AddAttribute (Object attributevalue) {assert.notnull (AttributeValue,"Model object must not being null"); if(AttributeValueinstanceofCollection && (collection<?>) AttributeValue). IsEmpty ()) {return This; } returnAddAttribute (Conventions.getvariablename (AttributeValue), AttributeValue); } PublicModelmap Addallattributes (collection<?>attributevalues) { if(Attributevalues! =NULL) { for(Object attributevalue:attributevalues) {AddAttribute (AttributeValue); } } return This; } PublicModelmap addallattributes (map<string,?>attributes) { if(Attributes! =NULL) {putall (attributes); } return This; } PublicModelmap mergeattributes (map<string,?>attributes) { if(Attributes! =NULL) { for(Map.entry<string,?>Entry:attributes.entrySet ()) {String key=Entry.getkey (); if(!ContainsKey (Key)) {Put (key, Entry.getvalue ()); } } } return This; } Public BooleanContainsattribute (String attributename) {returnContainsKey (AttributeName); }}
View:
PackageOrg.springframework.web.servlet;ImportJava.util.Map;Importjavax.servlet.http.HttpServletRequest;ImportJavax.servlet.http.HttpServletResponse;ImportOrg.springframework.http.MediaType; Public InterfaceView {String Response_status_attribute= View.class. GetName () + ". ResponseStatus"; String Path_variables= View.class. GetName () + ". Pathvariables"; String Selected_content_type= View.class. GetName () + ". Selectedcontenttype"; String getContentType (); voidRender (map<string,?> model, httpservletrequest request, httpservletresponse response)throwsException;}
Modelandview:
PackageOrg.springframework.web.servlet;ImportJava.util.Map;ImportOrg.springframework.ui.ModelMap;Importorg.springframework.util.CollectionUtils; Public classModelandview {PrivateObject View; PrivateModelmap model; Private Booleancleared =false; PublicModelandview () {} PublicModelandview (String viewName) { This. View =ViewName; } PublicModelandview (view view) { This. View =view; } PublicModelandview (String viewName, map<string,?>model) { This. View =ViewName; if(Model! =NULL) {Getmodelmap (). Addallattributes (model); } } PublicModelandview (view view, map<string,?>model) { This. View =view; if(Model! =NULL) {Getmodelmap (). Addallattributes (model); } } PublicModelandview (String viewName, String modelname, Object modelobject) { This. View =ViewName; AddObject (ModelName, modelobject); } PublicModelandview (view view, String modelname, Object modelobject) { This. View =view; AddObject (ModelName, modelobject); } Public voidsetviewname (String viewName) { This. View =ViewName; } PublicString Getviewname () {return( This. ViewinstanceofString? (String) This. View:NULL); } Public voidSetview (view view) { This. View =view; } PublicView GetView () {return( This. ViewinstanceofView? (View) This. View:NULL); } Public BooleanHasview () {return( This. View! =NULL); } Public Booleanisreference () {return( This. ViewinstanceofString); } protectedMap<string, object>getmodelinternal () {return This. Model; } PublicModelmap Getmodelmap () {if( This. Model = =NULL) { This. Model =NewModelmap (); } return This. Model; } PublicMap<string, object>Getmodel () {returnGetmodelmap (); } PublicModelandview AddObject (String attributename, Object attributevalue) {Getmodelmap (). AddAttribute (AttributeName , AttributeValue); return This; } PublicModelandview AddObject (Object attributevalue) {Getmodelmap (). AddAttribute (AttributeValue); return This; } PublicModelandview addallobjects (map<string,?>Modelmap) {Getmodelmap (). Addallattributes (Modelmap); return This; } Public voidClear () { This. View =NULL; This. Model =NULL; This. cleared =true; } Public BooleanIsEmpty () {return( This. View = =NULL&& Collectionutils.isempty ( This. Model)); } Public Booleanwascleared () {return( This. Cleared &&isEmpty ()); } @Override PublicString toString () {StringBuilder sb=NewStringBuilder ("Modelandview:"); if(IsReference ()) {Sb.append ("Reference to view with Name"). Append ( This. View). Append ("'"); } Else{sb.append ("Materialized View is ["). Append ( This. View). Append ('] '); } sb.append ("; Model is "). Append ( This. Model); returnsb.tostring (); }}
String:
void
Spring MVC processing Method return mode