package emp.shop.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import emp.shop.form.AdviceForm;
import emp.shop.idao.IAdviceDao;
import emp.shop.model.Advice;
import emp.shop.model.User;

public class AdvicingAction extends Action {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		AdviceForm af = (AdviceForm)form;
		
		ApplicationContext app = new ClassPathXmlApplicationContext("applicationContext-*.xml");
		IAdviceDao adviceDao = (IAdviceDao)app.getBean("adviceDaoProxy");
		Advice advice = (Advice)app.getBean("advice");
		User user = (User)app.getBean("user");
		
		user = (User) request.getSession().getAttribute("user");
		
		advice.setTitle(af.getTitle());
		advice.setContent(af.getContent());
		advice.setUser(user);
		
		adviceDao.addAdvice(advice);
		
		return mapping.findForward("success");
	}

}
最近下载更多
lyt010628  LV4 2024年7月9日
要用魔法打败魔法  LV2 2021年12月20日
为了水掉6位用户名  LV4 2021年8月20日
giantinheart  LV3 2021年5月22日
a14628909  LV4 2021年5月13日
浴皇大帝  LV8 2021年3月20日
lsglsg9  LV23 2021年1月4日
ldy666  LV8 2020年12月8日
长安tianzhu2  LV3 2020年9月14日
pdd1234  LV2 2020年7月10日
最近浏览更多
22050539325 5月9日
暂无贡献等级
蛋煎蟹 2024年12月17日
暂无贡献等级
571818771  LV3 2024年12月16日
sfzmn_0812 2024年8月12日
暂无贡献等级
lyt010628  LV4 2024年7月9日
1584435071 2024年6月23日
暂无贡献等级
孤独的根号三  LV1 2024年5月8日
WBelong  LV8 2023年12月11日
3273408633  LV2 2023年9月14日
zzz10086 2023年6月15日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友