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

📄 wealthcontroller.java

📁 一个不错的bbs论坛系统.对初学者很有帮助
💻 JAVA
字号:
package com.yhbbs.admin.web.sys;

import java.util.HashMap;
import java.util.Map;

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

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;

import com.yhbbs.admin.web.sys.form.WealthForm;
import com.yhbbs.bbs.biz.WealthBiz;
import com.yhbbs.bbs.itface.Wealth;
/**
 * <p>Title:论坛财富管理Controller</p>
 * <li>	论坛财富管理
 * <br><b>WebSite: www.yyhweb.com</b>
 * <br><b>CopyRight: yyhweb[由由华网]</b>
 * @author stephen
 * @version YHBBS-2.0
 */
public class WealthController extends SimpleFormController{
    // 构造函数设置其属性
	public WealthController(){
		this.setSessionForm(true);
		this.setValidateOnBinding(false);
		this.setCommandName("wealthForm");
		this.setFormView("wealth");
	}
	
    // 取得表单
	protected Object formBackingObject(HttpServletRequest request) throws Exception {
		Wealth wealth = WealthBiz.getWealth();
		if(wealth!=null)
			return new WealthForm(wealth);
		else
			return new WealthForm();
	}
	
	// 数据邦定和表单验证
//	protected void onBindAndValidate(HttpServletRequest request,Object command,BindException errors){
//		WealthForm wealthForm = (WealthForm)command;
//		System.out.println(wealthForm.getWealth().getLoginmoney());
//	}
	// 表单提交
	protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,BindException errors){
		Map<String, String> model = new HashMap<String, String>();
		WealthForm wealthForm = (WealthForm)command;
		if(WealthBiz.updateWealth(wealthForm.getWealth())){
			model.put("okinfo", "设置论坛财富");
			model.put("forward", "<a href='../admin/Wealth.do'>返回财富管理</a>");
			return new ModelAndView("success",model);
		}else{
			model.put("errinfo", "设置论坛财富");
			model.put("forward", "<a href='#' onclick='javascript:history.go(-1)'>返回财富管理</a>");
			return new ModelAndView("failure",model);
		}
	}
}

⌨️ 快捷键说明

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