addelectiveinfoformcontroller.java
来自「Spring+hibernate学生在线选课系统」· Java 代码 · 共 68 行
JAVA
68 行
/*
* Created on 2006-2-9
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.mmxbb.schoolelective.mvc.elective;
import java.util.ArrayList;
import java.util.Iterator;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mmxbb.schoolelective.model.Electivedetail;
import org.mmxbb.schoolelective.model.Electiveinfo;
import org.mmxbb.schoolelective.model.ShopCartInfo;
import org.mmxbb.schoolelective.mvc.course.AddCourseinfoFormController;
import org.mmxbb.schoolelective.util.StaticData;
import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class AddElectiveinfoFormController extends AbstractElectiveFormController {
protected static Log log = LogFactory.getLog(AddCourseinfoFormController.class);
public AddElectiveinfoFormController() {
// OK to start with a blank command object
setCommandClass(Electiveinfo.class);
// activate session form mode to allow for detection of duplicate submissions
setSessionForm(true);
}
protected ModelAndView onSubmit(HttpServletRequest request,HttpServletResponse response,Object command,BindException ex) throws Exception {
log.info("onSubmit is called");
Electiveinfo obj =(Electiveinfo)command;
getElectiveinfoService().createElectiveinfo(obj);
ArrayList shopCartList=(ArrayList)request.getSession().getAttribute(StaticData.SHOPCART_KEY);
Iterator it=shopCartList.iterator();
while(it.hasNext()){
ShopCartInfo sci=(ShopCartInfo)it.next();
Electivedetail od=new Electivedetail();
od.setElectiveid(obj.getId());
od.setCourseid(sci.getId());
od.setCoursename(sci.getName());
od.setAmout(sci.getAmount());
getElectivedetailService().createElectivedetail(od);
}
request.getSession().setAttribute(StaticData.SHOPCART_KEY,null);
return new ModelAndView(getSuccessView(),"electiveinfo",obj);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?