????1????д????????????????????????Action????в???????????????????????????????????
?????????????UserAction??????ж????????????????????????????
public String register() throws Exception{
if("" == user.getUsername()||""==user.getPassword()){
return "error";
}
else{
userService.saveUser(user);
return SUCCESS;
}
}
?????????UserAction????????????????
package org.easybooks.bookstore.action;
import org.easybooks.bookstore.service.IUserService;
import org.easybooks.bookstore.vo.User;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/*
* ???????????
*  Actor???????
* */
public class UserActionTest {
@Test
public void testRegisterSuccess() throws Exception {
BeanFactory factory = new ClassPathXmlApplicationContext("applicationContext.xml");
User user=new User();
user.setUsername("WYH");
user.setPassword("123456");
user.setSex("?");
user.setAge(23);
UserAction userAction=new UserAction();
userAction.setUser(user);
userAction.setUserService((IUserService)factory.getBean( "userService" ));
String result=userAction.register();
System.out.println("???:"+user.getUsername()+"???"+result);
}
}
?????????????????????????????????