毕业论文http://www.youerw.com
<form-bean name="userForm" type="com.xiamen.oa.module.user.form.UserForm" />
</form-beans>
<action
attribute="userForm"
input="/module/user/userlist.jsp"
name="userForm"
path="/user"
scope="request"本文来自优'文,论.文,网
parameter="task"
type="com.xiamen.oa.module.user.action.UserAction" >
<forward name="add" path="/module/user/user.jsp"/>
<forward name="look" path="/module/user/look.jsp"/>
<forward name="index" path="/module/index.jsp" redirect="true"/>
</action>
</action-mappings>
<controller
processorClass="org.springframework.web.struts.DelegatingRequestProcessor">
</controller>
<message-resources parameter="com.xiamen.struts.ApplicationResources" />
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext-*.xml" />
</plug-in>
</struts-config>
(2)ActionForm是视图层和控制器层交互的桥梁,它负责将页面的参数转化成变量属性,在模型层中可以得到这些变量属性,完成业务逻辑工作。对应之前struts-config.xml中的<form-bean>元素,提供一个名为UserForm的ActionForm。
(3)编写实现类。创建UserDAOImpl类,核心代码如下。
public List searchUserFunction(String userid) {
String sql = "select * from c_function where funid in(select distinct funid from c_rolefunction where roleid in(select roleid from c_userrole where userid='"
+ userid + "'))";
return jdbcTemplate.queryForList(sql);
}
public List searchUserRoles(String userid) {
String sql = "select * from c_userrole where userid=" + userid;
return jdbcTemplate.queryForList(sql);
}
(4)Action对象是Struts中最接近核心业务的部分,它负责整个模型层的工作,在业务逻辑处理结束后,还可以转发到特定的页面。对应之前struts-config.xml的<action>元素,提供一个名为UserAction的Action对象,核心代码如下:
public ActionForward login(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UserForm userForm = (UserForm) form;
毕业论文http://www.youerw.com
} catch (IOException e) {
e.printStackTrace();
}
if (userBean != null) {
if (request.getParameter("code").equals(
request.getSession().getAttribute("rand"))) {
if (userBean.getSpwd().equals(userForm.getSpwd())) {
if (userBean.getSlock().equals("0")) {
上一页 [1] [2] [3] [4] [5] [6] [7] [8] 下一页