我已經使用了兩種方法。
第一種方法,使用的web.xml與檢票應用程序初始化參數:
<filter>
<filter-name>WicketApp</filter-name>
<filter-class>
org.apache.wicket.protocol.http.WicketFilter
</filter-class>
<init-param>
<param-name>applicationFactoryClassName</param-name>
<param-value>
org.apache.wicket.spring.SpringWebApplicationFactory
</param-value>
</init-param>
<init-param>
<param-name>param1</param-name>
<param-value>xxx.xxx.xxx.xxx</param-value>
</init-param>
<init-param>
<param-name>param2</param-name>
<param-value>Hello</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>WicketApp</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
您可以通過訪問它們:
MyApplication.get().getInitParameter("param1")
第二種方法,如果你使用Spring,你可以用你的applicationContext.xml參數化您的beans:
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="mail.xxx.com"/>
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.sendpartial">true</prop>
</props>
</property>
</bean>