51,411
社区成员
发帖
与我相关
我的任务
分享
<bean id="SBrandController"
class="UEngine.Younext.Controller.SBrandController">
<property name="commandClass"><value>UEngine.Younext.PO.BrandForm</value></property>
<property name="cnUtil"><ref bean="CnUtil"/></property>
<property name="sessionUtil"><ref bean="SessionUtil"/></property>
<property name="userGlobalCheck"><ref bean="UserGlobalCheck"/></property>
<property name="brandDAO"><ref bean="BrandDAO"/></property>
<property name="brandAdd" value="brandAdd"/>
<property name="brandMdy" value="brandMdy"/>
<property name="brandList" value="brandList"/>
<property name="redirectPage" value="login.do"/>
</bean>
public class SBrandController extends SimpleFormController {
CnUtil cnUtil;
SessionUtil sessionUtil;
UserGlobalCheck userGlobalCheck;
IBrandDAO brandDAO;
String brandAdd,brandMdy,brandList,redirectPage;
public ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response,
Object command,
BindException exception)
throws Exception {
BrandForm brandForm = (BrandForm)command;
System.out.println("s start");
if(!this.getUserGlobalCheck().checkOnlineUser(request)){
return new ModelAndView(new RedirectView(this.getRedirectPage()));
}
int userViewID = 0;
if(cnUtil.RidNull(brandForm.getBrandName()).length() > 50 || cnUtil.RidNull(brandForm.getBrandName()).length() <= 0){
System.out.println("e01");
return findModelAndView(brandForm.getSMethod(), exception, "品牌信息的合法长度为1 - 25个字符!");
}
if(cnUtil.RidNull(brandForm.getSMethod()).equalsIgnoreCase("add")){
if(this.getBrandDAO().existSameBrandByUIDAndBName(userViewID, cnUtil.RidNull(brandForm.getBrandName()))){
System.out.println("e02");
return findModelAndView(brandForm.getSMethod(), exception, "您所添加的品牌已存在!");
}
}
if(cnUtil.RidNull(brandForm.getSMethod()).equalsIgnoreCase("mdy") && brandForm.getBrandID() <= 0){
return findModelAndView(brandForm.getSMethod(), exception, "数据处理出错!如有任何问题请与管理员联系!!");
}
System.out.println("s 01");
Brand brandInfo = new Brand();
if(cnUtil.RidNull(brandForm.getSMethod()).equalsIgnoreCase("mdy")){brandInfo.setBrandid(new Integer(brandForm.getBrandID()));}
brandInfo.setBrandname(cnUtil.RidNull(brandForm.getBrandName()));
brandInfo.setUserid(new Integer(userViewID));
this.getBrandDAO().saveBrandInfo(brandInfo);
System.out.println("s 02");
return new ModelAndView(this.getBrandList());
}
public ModelAndView findModelAndView(String fromUrl, BindException exception, String errorCode){
exception.rejectValue("brandName", "no_brandName", errorCode);
if(cnUtil.RidNull(fromUrl).equalsIgnoreCase("mdy")){
return new ModelAndView(this.getBrandMdy(), exception.getModel());
}else{
return new ModelAndView(this.getBrandAdd(), exception.getModel());
}
}
public CnUtil getCnUtil() {
return cnUtil;
}
public void setCnUtil(CnUtil cnUtil) {
this.cnUtil = cnUtil;
}
public SessionUtil getSessionUtil() {
return sessionUtil;
}
public void setSessionUtil(SessionUtil sessionUtil) {
this.sessionUtil = sessionUtil;
}
public UserGlobalCheck getUserGlobalCheck() {
return userGlobalCheck;
}
public void setUserGlobalCheck(UserGlobalCheck userGlobalCheck) {
this.userGlobalCheck = userGlobalCheck;
}
public IBrandDAO getBrandDAO() {
return brandDAO;
}
public void setBrandDAO(IBrandDAO brandDAO) {
this.brandDAO = brandDAO;
}
public String getBrandAdd() {
return brandAdd;
}
public void setBrandAdd(String brandAdd) {
this.brandAdd = brandAdd;
}
public String getBrandMdy() {
return brandMdy;
}
public void setBrandMdy(String brandMdy) {
this.brandMdy = brandMdy;
}
public String getRedirectPage() {
return redirectPage;
}
public void setRedirectPage(String redirectPage) {
this.redirectPage = redirectPage;
}
public String getBrandList() {
return brandList;
}
public void setBrandList(String brandList) {
this.brandList = brandList;
}
}
public class BrandForm {
private int brandID;
private String brandName;
private String sMethod;
public int getBrandID() {
return brandID;
}
public void setBrandID(int brandID) {
this.brandID = brandID;
}
public String getBrandName() {
return brandName;
}
public void setBrandName(String brandName) {
this.brandName = brandName;
}
public String getSMethod() {
return sMethod;
}
public void setSMethod(String method) {
sMethod = method;
}
}<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="taglibs.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="css/younext.css">
<title>younext</title>
</head>
<body>
<form name='form' action='sbrand.do' method='post'>
<spring:bind path="command.*">
<font color="red"> <b>${status.errorMessage}</b> </font>
</spring:bind>
<table cellpadding="2" cellspacing="1" border="0" width="300" class="border" align="left">
<tr class="title">
<td><strong>品牌--增加</strong>
<input type='text' name='sMethod' value='add'>
<input type='text' name='brandID' value='0'>
</td>
</tr>
<tr class="tdbg">
<td>
</td>
</tr>
<tr class="tdbg">
<td>名称:</td>
</tr>
<tr>
<td class="tdbg">
<spring:bind path='command.brandName'>
<input type='text' name='${status.expression}' value='${status.value}'>
</spring:bind>
</td>
</tr>
<tr class="tdbg">
<td align="center"><input type='submit' value='添加'></td>
</tr>
</table>
</form>
</body>
</html>type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute