欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

一点经验

程序员文章站 2022-03-24 11:03:42
...
(1)有关增加修改页面信息的初始化
以前是以为在
    private ActionForward performDoperson(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) {
。。。
        request.setAttribute("tab_xn_adminForm", form);  //hehe
}
里面对form进行付值,
然后在jsp页面用语句
<%@ page import="com.srt.vas.dummymain.backgroud.controller.Tab_xn_adminForm"%>
<%
    Tab_xn_adminForm tab_xn_adminForm = new Tab_xn_adminForm();
    if (request.getAttribute("tab_xn_adminForm") != null) {
        tab_xn_adminForm = (Tab_xn_adminForm)request.getAttribute("tab_xn_adminForm");
}
%>
进行取值,
但好象不是,如果是只有表单内容,可以在jsp不用写那些语句
如果用到下拉框,并且是用其他方法获得,写那些list的request.setAttribute后,在jsp里面也不用声明的。
(2)有关form和model(有关全局变量和局部变量)
在有关提交用户form的时候最好都在struts-config.xml文件中配置form,这样在处理form页面信息的时候就简单了
private ActionForward performSave(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) {
        Tab_ch_musicForm form = (Tab_ch_musicForm) actionForm;   
    ProjectUtil projectUtil = new ProjectUtil();
        try {
            Tab_ch_musicDAO tab_ch_musicDAO = new Tab_ch_musicDAO();
            Tab_ch_music tab_ch_music = new Tab_ch_music();            org.apache.commons.beanutils.BeanUtils.populate(tab_ch_music, org.apache.commons.beanutils.BeanUtils.describe(form));