一、做Action相关的准备
•Action、JSP、配置
1,创建 MyAction extends BaseAction.
2,定义出Action中的方法,要写出方法名、作用、返回值。
3,创建出所用到的JSP页面(目前还没有具体内容)。
4,配置Action:
1,在MyAction上写注解@Controller与@Scope("prototype").
2,在strtus.xml中配置这个Action与所用到的result.
二、做Service相关的准备
•接口、实现类、配置1,创建接口MyService extends BaseDao.
2,创建实现类MyServiceImpl extends BaseDaoImpl.
3,配置:在MyServiceImpl上写注解:
@Service与 @Transactional
4,声明:在BaseAction中声明:
@Resource
protected MyService myService;
三、填空
•Action方法、Service方法、JSP页面
1,Action方法。
2,新增的Service方法。
3,JSP页面的内容:
a,拷贝静态页面中的源代码到JSP中。
b,包含进来公共的资源:
<%@ include file=“../public/commons.jspf" %>
c,把 ../ 替换为 ${pageContext.request.contextPath}/
d,修改页面内容(使用自定义标签)
1,( Action中)添加功能的步骤:
// 1,新建对象并设置属性(在model使用的是实体的情况下,也可以使用model,但需要设置未封装的属性)
// 2,保存到数据库
2,( Action中))修改功能的步骤:
// 1,从数据库中取出原对象
// 2,设置要修改的属性
// 3,更新到数据库
(JSP)改页面内容(使用自定义标签):
1,列表页面:
<s:iterator value="..">
<s:a action="..">
2,表单页面(saveUI.jsp):
<s:form action="departmentAction_%{id == null ? 'add' : 'edit'}">
<s:hidden name="id"/>
<s:textfield>
<s:textarea>
<s:select name=".." list=".." listKey=".." listValue="..">
<s:radio>
<s:checkbox>
<s:submit>
...
</s:form>