⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addcatfc.java

📁 sping下勇Xdoclet开发hibernate的程序实例,版本hibernate2.0,开发工具eclipse3.0
💻 JAVA
字号:
package org.ggyy.web.ctrl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.ggyy.bo.Cat;
import org.ggyy.web.cmd.CatCmd;
import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

/**
 * 
 * spring的控制器,类似于struts的Action
 *
 */
/**
 * @author jiangyubao
 * @spring.bean id="addCatFC"
 * @spring.property name="catDao" ref="catDao"
 * @spring.property name="validator" ref="catFVLD"
 * @spring.property name="formView" value="catForm.jsp"
 * @spring.property name="sessionForm" value="true"
 */
public class AddCatFC extends AbstractPetFC {

    public AddCatFC() {
        this.setCommandClass(Cat.class);
    }

    protected ModelAndView onSubmit(HttpServletRequest request,
            HttpServletResponse response, Object command, BindException errors)
            throws Exception {
        String parentId = request.getParameter("parentId");
        Cat parent = null;
        if (parentId != null && !parentId.equals("")) {
            parent = (Cat) this.getCatDao().load(parentId);
        }
        Cat cat = (Cat) command;
        cat.setParent(parent);
        this.getCatDao().store(cat);
        return new ModelAndView(new RedirectView("listCat.sf"), "parentId", cat
                .getParent() != null ? cat.getParent().getId() + "" : cat
                .getId()
                + "");

    }

    protected ModelAndView handleInvalidSubmit(HttpServletRequest request,
            HttpServletResponse response) throws Exception {

        return this.disallowDuplicateFormSubmission(request, response);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -