【Java开源代码栏目提醒】:网学会员为需要Java开源代码的朋友们搜集整理了ContentTypeAction.java相关资料,希望对各位网友有所帮助!
package com.myEdition.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//导入struts包
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 com.myEdition.bean.ContentType;
import com.myEdition.domain.SetContentType;
//继承action
public class ContentTypeAction extends Action {
private SetContentType setContentType;
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
//获取用户提交的信息
ContentType contentType = (ContentType)form;
//保存用户提交的信息
getSetContentType().saveContentType(contentType);
//将用户提交的信息和是否保存成功的信息存放在request中
request.setAttribute("contentType", contentType);
request.setAttribute("userId", (String)request.getParameter("userId"));
request.setAttribute("username", (String)request.getParameter("username"));
request.setAttribute("msg", getSetContentType().getMsg());
//返回页面
return mapping.findForward("success");
}
/**返回setContentType
*/
public SetContentType getSetContentType() {
return setContentType;
}
/**设定setContentType
*/
public void setSetContentType(SetContentType setContentType) {
this.setContentType = setContentType;
}
}
上一篇:
ContentType.java
下一篇:
法律专业开题报告范文