这两天看JPetStore(ibatis和struts),我原想把struts标签都改成el和jstl(需要加standard和jstl jar文件)。结果把html 改的过程出了很多问题,html:text /areatext /radio/checkbox/ select/ option必须包含在html:form中,它们的property要对应form 的action对应的bean,select/ option比较麻烦。所以总结出来,改造过程可以分两步走:1 html:from部分不变,其中还涉及验证,2bean和logic可以改为el和jstl,不过改了之后竟然识别不出来。。郁闷,只好先暂停。。
在程序中文件的后缀名改为shtml,每一个页面都经过servlet。
下面是beanaction的内容:
private static final String NO_METHOD_CALL = "*";
private static final String SUCCESS_FORWARD = "success";
public final ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
String forward = SUCCESS_FORWARD;
try {
if (!(form instanceof BaseBean)) {
if (form != null) { ........... } else { .............. }
}
BaseBean bean = (BaseBean) form;
ActionContext.initCurrentContext(request, response);
if (bean != null) {
// Explicit Method Mapping
Method method = null;
String methodName = mapping.getParameter();
if (methodName != null && !NO_METHOD_CALL.equals(methodName)) {
try {
method = bean.getClass().getMethod(methodName, null);
synchronized (bean) {
forward = bean.getInterceptor().intercept(new ActionInvoker(bean, method));
}
} catch (Exception e) {
..........
}
}
// Path Based Method Mapping
if (method == null && !NO_METHOD_CALL.equals(methodName)) {
methodName = mapping.getPath();
if (methodName.length() > 1) {
int slash = methodName.lastIndexOf("/") + 1;
methodName = methodName.substring(slash);
if (methodName.length() > 0) {
try {
method = bean.getClass().getMethod(methodName, null);
synchronized (bean) {
forward = bean.getInterceptor().intercept(new ActionInvoker(bean, method));
}
} catch (Exception e) {
.......
}
}
}
}
}
} catch (Exception e) {
forward = "error";
request.setAttribute("BeanActionException", e);
}
return mapping.findForward(forward);
}
BeanActionException(RuntimeException) 很值得学习4个构造函数 super()/super(string)/super(throwable)/super(string,throwable)
ActionContext (cookieMap parameterMap requestMap sessionMap applicationMap/request/response)
abstract class BaseHttpMap拥有四个抽象的方法getNames() /getValue()/putValue()/removeValue())
abstract class BaseHttpMap implements Map 要实现map的一些方法。
throw new UnsupportedOperationException("Cannot put value to ParameterMap.");
分享到:
相关推荐
该jpetstore经典案例为最新SPRING开发包里面的完全案例,并集成到eclipse里面了,在eclipse里面可以直接运行并调试,在工作目录里面直接建立jpetstore目录,自动导入该目录下文件,修改jdbc.properties配置文件,连接...
jpetstore系统架构图
iBATIS JPetStore
学习Spring 的例子JpetStore
jpetstore学习j2ee的好资料,可以学到很多的设计模式
iBATIS_JPetStore-4.0.5
使用了mybatis的jpetstore-6
用spring改造的jpetstore4.0,适用于jdk7+,tomcat6+。mysql数据库
jpetstore-4.0.3
AJAX开发。在JSP/Servlet实现的JPetStore项目基础上,在表单验证、表单输入、订单更新等环节增加AJAX技术,改善项目的用户体验。以下三个任务为必须完成部分,还可自行添加其他改进用户体验的功能。
jpetstore源码,在myeclipse已经可以运行起来
ssh版jpetstore 可不好找,终于让我找到了, 大家可以下来看看
该程序是jpetstore宠物店程序,放在tomcat的webapps的目录下就能运行。修改jdbc.properties的数据库密码,先将两个sql文件导入mysql数据库中。
JPetStore项目分析——分析一个典型J2EE应用web层的实现 ,JPetStore是Sun公司开发的,在大众化的宠物商店程序基础上完全重写的,最早的基于J2EE平台的宠物商店网络应用服务程序。与其它的PetStore最本质的不同是...
jpetstore.rarjpetstore.rarjpetstore.rarjpetstore.rarjpetstore.rarjpetstore.rarjpetstore.rarjpetstore.rarjpetstore.rarjpetstore.rarjpetstore.rarjpetstore.rarjpetstore.rar
jpetstore,支持多种数据库 采用了ibatis框架
这是使用Struts+Spring+Hibernate实现jpetstore的功能的源代码
Jpetstore