1. 前提:
2. 修改MyNewControllerCmdImpl.java实现类:
/// Section 2 >
/// The controller command passes variables to the JSP page>
/// add additional parameters in controller command to rspProp
/// for response
String message1 = "Hello from IBM!";
rspProp.put("controllerParm1", message1);
rspProp.put("controllerParm2", "Have a nice day!");>
/// End of section 2/
3. 更新MyNewJSPTemplate.jsp页面,获取Controller返回set值:
a. 在MyNewJSPTemplate.jsp中增加下面代码(教程中可从MyNewJSPTemplate_All.jsp获取),其中ParametersFromCmd为配置文件TutorialNLS.properties里面对应值,ControllerParm1、ControllerParm2为Controller实现类set值:
<!-- SECTION 4 -->
<h3>
<fmt:message key="ParametersFromCmd" bundle="${tutorial}" />
</h3>
<fmt:message key="ControllerParm1" bundle="${tutorial}" />
<c:out value="${controllerParm1}"/>
<br />
<fmt:message key="ControllerParm2" bundle="${tutorial}" />
<c:out value="${controllerParm2}"/>
<br />
<br />
<!-- END OF SECTION 4 -->
4. 测试:
a. 启动server
b. 访问: http://localhost/webapp/wcs/stores/servlet/MyNewControllerCmd (注:由于缓存可在url后加如: ?StoreId=10051 )
参考: