package com.my.dzzw.action; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import java.io.File; import javax.servlet.http.HttpSession; import org.apache.struts2.ServletActionContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; import com.my.dzzw.utils.Pager; import com.my.dzzw.utils.UserUtils; import com.opensymphony.xwork2.ModelDriven; import java.util.*; import com.my.dzzw.model.*; import com.my.dzzw.dao.*; import com.my.dzzw.service.*; /** * * 项目名称:dzzw * 类名称:MessageAction * 类描述: 信息控制类 * 创建人:君无邪 * 创建时间:2018年09月15日 下午2:42:25 * 修改备注: https://www.java214.com * @version 1.0 * */ @Controller("messageAction") @Scope("prototype") public class MessageAction extends ActionSupport implements ModelDriven<Message>{ private static final long serialVersionUID = 1L; //==========model============== private Message message; @Override public Message getModel() { if(message==null) message = new Message(); return message; } //==========model============== /** * 依赖注入 start dao/service/=== */ @Autowired private MessageService messageService; //依赖注入 end dao/service/=== //-------------------------华丽分割线--------------------------------------------- //============自定义参数start============= //============自定义参数end============= //-------------------------华丽分割线--------------------------------------------- //============文件上传start======================================================= private File file; //提交过来的file的名字 private String fileFileName; //提交过来的file的MIME类型 private String fileContentType; public File getFile() { return file; } public void setFile(File file) { this.file = file; } public String getFileFileName() { return fileFileName; } public void setFileFileName(String fileFileName) { this.fileFileName = fileFileName; } public String getFileContentType() { return fileContentType; } public void setFileContentType(String fileContentType) { this.fileContentType = fileContentType; } //============文件上传end========================================================= //-------------------------华丽分割线---------------------------------------------// //=============公=======共=======方=======法==========区=========start============// /** * 列表分页查询 */ public String message(){ Map<String,Object> alias = new HashMap<String,Object>(); StringBuffer sb = new StringBuffer(); sb = sb.append("from Message where 1=1 "); sb = sb.append("order by id desc"); Pager<Message> pagers = messageService.findByAlias(sb.toString(),alias); ActionContext.getContext().put("pagers", pagers); ActionContext.getContext().put("Obj", message); return SUCCESS; } /** * 跳转到添加页面 * @return */ public String add(){ ActionContext.getContext().put("Obj", message); return SUCCESS; } /** * 执行添加 * @return */ public String exAdd(){ HttpSession session = ServletActionContext.getRequest().getSession(); if(session.getAttribute("userId") != null){ message.setIsDelete(0); message.setUser(UserUtils.getUser()); messageService.save(message); ActionContext.getContext().put("url", "/message_add.do?type="+message.getType()); return "redirect"; }else{ return "uLogin"; } } /** * 查看详情页面 * @return */ public String view(){ Message n = messageService.getById(message.getId()); ActionContext.getContext().put("Obj", n); return SUCCESS; } /** * 跳转修改页面 * @return */ public String update(){ Message n = messageService.getById(message.getId()); ActionContext.getContext().put("Obj", n); return SUCCESS; } /** * 执行修改 * @return */ public String exUpdate(){ Message n = messageService.getById(message.getId()); messageService.update(n); ActionContext.getContext().put("url", "/message_message.do"); return "redirect"; } /** * 删除 * @return */ public String delete(){ messageService.delete(message.getId()); ActionContext.getContext().put("url", "/message_message.do"); return "redirect"; } //=============公=======共=======方=======法==========区=========end============// //-------------------------华丽分割线---------------------------------------------// //=============自=======定=======义=========方=======法==========区=========start============// //=============自=======定=======义=========方=======法==========区=========end============// }

justoday LV11
2024年9月11日
guo0326 LV1
2024年3月28日
笑得很美 LV11
2024年3月13日
xiongwei11231 LV9
2023年8月31日
北方菜 LV11
2022年12月30日
12koko LV3
2022年11月3日
zhaoyangwfd LV17
2022年9月28日
唐僧洗头爱飘柔 LV22
2022年8月22日
testuser1234567 LV24
2022年6月30日
ᯤ⁵²¹ᴳ⁺ LV8
2022年4月6日