Webwork2使用经验四则

类别:Java 点击:0 评论:0 推荐:
1.jar包中的taglib使用
WebLogic是不支持直接在jar包中使用taglib的,所以,一个在tomcat下运行正常的页面,在weblogic server下可能出错:
Parsing of JSP File '/globalList.jsp' failed:
--------------------------------------------------------------------------------
 /globalList.jsp(2): Could not parse deployment descriptor: java.io.IOException: cannot resolve 'webwork' into a valid tag library
probably occurred due to an error in /globalList.jsp line 2:
<%@ taglib prefix="ww" uri="webwork"%>
--------------------------------------------------------------------------------
Tue Jan 11 15:34:02 CST 2005
解决办法:在web.xml中加入下面的内容
<taglib>
<taglib-uri>webwork</taglib-uri>
<taglib-location>/WEB-INF/lib/webwork-2.1.jar</taglib-location>
</taglib> 2.model的构造
webwork是不负责为你构造model的,所以你的action中应该这样构造model:
private ModelInfo modelInfo=new ModelInfo();
如果你写 private ModelInfo modelInfo会报错的. 3.使用ioc
webwork的ioc也需要你自己构造要组建的对象,所以你的model中应该这样写:
public class ModelInfo {
 private List workList=new ArrayList();
 private String actionTypeEnglish="";
 private String actionType="";
 private String actionHref="";
 ..........
如果不对List做初始化,系统会报NullPointerException 4.传递到view的model
必须自己为传递到view的model赋值:
ModelInfo model=service.getList(orgId);
   modelInfo.getWorkList().addAll(model.getWorkList());
   modelInfo.setActionHref(model.getActionHref());
   modelInfo.setActionType(model.getActionType());
   modelInfo.setActionTypeEnglish(model.getActionTypeEnglish());
不调用set方法,传递到view的model将是空的.
 

本文地址:http://com.8s8s.com/it/it11949.htm