Announcement Announcement Module
Collapse
No announcement yet.
Initialize bean that has HashMap Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Initialize bean that has HashMap

    I asked the same question in web forum but was answered..so asking it seems like the right forum.

    How to I initialize the PageMappingBean in spring-mvc.xml or something ? I am doing something similar to viewResolver but I have single controller that serves all pages so the plain view resolver is not very useful for me.

    Class PageMappingsBean {
    HashMap<String,PageMapping> pageMap = new HashMap<String,PageMapping>();
    //getter and setters
    }

    Class PageMapping {
    String TemplateName;
    String ContentName;
    bool isSecure;
    //getter and setters
    }

  • #2
    How to I initialize the PageMappingBean in spring-mvc.xml or something ?
    By initialize do you mean populating the pageMap? If so, It would be something like,

    Code:
    	<bean id="pageMappingsBean" class="com.web.PageMappingsBean ">
    		<property name="pageMap" ref="pageMap" />
    	</bean>
    
    	<util:map id="pageMap" map-class="java.util.HashMap">
    		<entry key="page1" value-ref="page1" />
    		<entry key="page2" value-ref="page2" />
    	</util:map>
    
    	<bean id="page1" class="PageMapping ">
    		<property name="TemplateName" value="blabla"/>
    		<property name="ContentName" value="blabla"/>
    		<property name="isSecure" value="true"/>
    	</bean>
    	
    	<bean id="page2" class="PageMapping ">
    		<property name="TemplateName" value="blabla"/>
    		<property name="ContentName" value="blabla"/>
    		<property name="isSecure" value="true"/>
    	</bean>
    I have single controller that serves all pages so the plain view resolver is not very useful for me.
    How one controller serving all the requests or multiple controller serving request makes any difference when it comes to the view resolver?

    Comment

    Working...
    X