在jsp页面中点击提交,出现以下的错误:
java.lang.RuntimeException: Invalid action class configuration that references an unknown class named [userAction]
这是提示没有userAction,这里是没有错的,因为我有其他的地方也用到了这个Action,而且都没报错,有的时候点击提交没报这个错误的时候呢,但对应的方法却没执行到,这是怎么回事呢?下面贴下Action中对应的那个方法的代码:
public String saveTeacher() throws Exception{
System.out.println("this.getName()");
System.out.println(this.getTeacherid());
HttpSession httpSession=ServletActionContext.getRequest().getSession();
if(httpSession.getAttribute("admin")!=null){
if(this.getTeacherid()!=null && this.getName()!=null && this.getPhoto()!=null){
Teacher tea=new Teacher();
try{
FileInputStream fis=new FileInputStream(this.getPhoto());
byte[] buffer=new byte[fis.available()];
fis.read(buffer);
tea.setPhoto(buffer);
tea.setTid(this.getTeacherid());
tea.setName(this.getName());
tea.setBirthday((String)this.getBirthday());
tea.setSchool(this.getSchool());
tea.setDegree(this.getDegree());
tea.setPosition(this.getPosition());
tea.setContact(this.getContact());
tea.setIntro(this.getIntro());
userService.saveTeacher(tea);
return SUCCESS;
}catch(Exception e){
return ERROR;
}
}else{
JOptionPane.showMessageDialog(null, "教工号、教师姓名或教师相片允许为空,上传失败!");
return INPUT;
}
}else{
JOptionPane.showMessageDialog(null, "您尚未登陆,请登陆!");
return LOGIN;
}
}
java.lang.RuntimeException: Invalid action class configuration that references an unknown class named [userAction]
这是提示没有userAction,这里是没有错的,因为我有其他的地方也用到了这个Action,而且都没报错,有的时候点击提交没报这个错误的时候呢,但对应的方法却没执行到,这是怎么回事呢?下面贴下Action中对应的那个方法的代码:
public String saveTeacher() throws Exception{
System.out.println("this.getName()");
System.out.println(this.getTeacherid());
HttpSession httpSession=ServletActionContext.getRequest().getSession();
if(httpSession.getAttribute("admin")!=null){
if(this.getTeacherid()!=null && this.getName()!=null && this.getPhoto()!=null){
Teacher tea=new Teacher();
try{
FileInputStream fis=new FileInputStream(this.getPhoto());
byte[] buffer=new byte[fis.available()];
fis.read(buffer);
tea.setPhoto(buffer);
tea.setTid(this.getTeacherid());
tea.setName(this.getName());
tea.setBirthday((String)this.getBirthday());
tea.setSchool(this.getSchool());
tea.setDegree(this.getDegree());
tea.setPosition(this.getPosition());
tea.setContact(this.getContact());
tea.setIntro(this.getIntro());
userService.saveTeacher(tea);
return SUCCESS;
}catch(Exception e){
return ERROR;
}
}else{
JOptionPane.showMessageDialog(null, "教工号、教师姓名或教师相片允许为空,上传失败!");
return INPUT;
}
}else{
JOptionPane.showMessageDialog(null, "您尚未登陆,请登陆!");
return LOGIN;
}
}
<result name="success">/admin/savesuccess.jsp</result>
<result name="error">/admin/saveerror.jsp</result>
<result name="login">/admin/adminlogin.jsp</result>
<result name="input">/admin/teacheradd.jsp</result>
</action>
<bean id="userDAO" class="org.course.dao.impl.UserDAO">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="userService" class="org.course.service.impl.UserService">
<property name="userDAO">
<ref bean="userDAO"/>
</property>
</bean>
<bean id="userAction" class="org.course.action.UserAction">
<property name="userService">
<ref bean="userService"/>
</property>
</bean>