package project001.admin.web;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import project001.admin.entity.WebInfo;
import project001.admin.impl.webInfoImpl;
import project001.admin.model.WebInfoModel;
@Controller
@RequestMapping("/admin/Config")
public class ConfigController {
@RequestMapping("/index")
public ModelAndView index(){
return new ModelAndView("/admin/config/index","command",new WebInfoModel());
}
@RequestMapping("/submit")
public String submit(WebInfoModel webInfoModel){
WebInfo webInfo = webInfoImpl.get(0);
webInfo.setTitle(webInfoModel.getTitle());
webInfo.setCopyright(webInfoModel.getCopyright());
webInfo.setKeyword(webInfoModel.getKeyword());
webInfo.setDescription(webInfoModel.getDescription());
webInfoImpl.update(webInfo);
return "redirect:index";
}
}
public String submit方法里面的代码能优化下吗?
如何字段很多的话.那要写很多webInfo.set......那就工作量大了.
能不能通过枚举或者循环来做?
构造函数,bean里面set值的时候返回对象本身等等