自动生成几个文件:
并且,spring的applicationContext.xml自动加入
然后,建立ftl页面,根据前面web.xml配置的freemarker设置,需要建立如下目录
先把页面逻辑处理下,打开struts-config.xml,然后进行如下操作
继续加
完成后效果如下:
下面是3个页面:
这里注意下前2行,在freemarker中用struts标签。
前面说过action委托给spring做,许要在struts那加入
然后,action类需要修改下
下面的setter是为spring准备的。
struts配置那的action声明需要修改一下,说明用代理:
然后在spring的applicationContext.xml加上:
注意是用name,不是id。
发布,运行,结果抛了个错
还好,问题不大,找到
加到WEB-INF/lib下就可以了。
开始测试
成功的话:
否则:
然后去数据库一看,郁闷,数据没进来,试了N久,最后发现spring里要定义个dataSource。原来sessionFactory的定义变为如下:
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/35.jpg)
并且,spring的applicationContext.xml自动加入
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/36.jpg)
然后,建立ftl页面,根据前面web.xml配置的freemarker设置,需要建立如下目录
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/37.jpg)
先把页面逻辑处理下,打开struts-config.xml,然后进行如下操作
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/38.jpg)
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/39.jpg)
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/40.jpg)
继续加
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/41.jpg)
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/42.jpg)
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/43.jpg)
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/44.jpg)
完成后效果如下:
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/45.jpg)
下面是3个页面:
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/46.jpg)
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/47.jpg)
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/48.jpg)
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/49.jpg)
这里注意下前2行,在freemarker中用struts标签。
前面说过action委托给spring做,许要在struts那加入
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/50.jpg)
然后,action类需要修改下
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/51.jpg)
下面的setter是为spring准备的。
struts配置那的action声明需要修改一下,说明用代理:
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/59.jpg)
然后在spring的applicationContext.xml加上:
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/52.jpg)
注意是用name,不是id。
发布,运行,结果抛了个错
![Click here to open new windowCTRL+Mouse wheel to zoom in/out](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/53.jpg)
还好,问题不大,找到
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/54.jpg)
开始测试
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/55.jpg)
成功的话:
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/56.jpg)
否则:
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/57.jpg)
然后去数据库一看,郁闷,数据没进来,试了N久,最后发现spring里要定义个dataSource。原来sessionFactory的定义变为如下:
![](http://www.host01.com/UpLoadFiles/UpPic/2006-9/1/58.jpg)