Struts2整合Spring從xml到註解
阿新 • • 發佈:2019-02-14
- @Namespace("/")
- @Component(value="userLogin")
- @Scope(value="prototype")
- publicclass LoginAction extends ActionSupport {
- public LoginAction() {
- super();
- // TODO Auto-generated constructor stub
- System.out.println("action:"+this.hashCode());
- }
- @Autowired
- private
- private User user;
- public User getUser() {
- return user;
- }
- publicvoid setUser(User user) {
- this.user = user;
- }
- @Autowired
- publicvoid setBiz(ILoginBiz biz) {
- this.biz = biz;
- }
- @Override
- @Action(value = "hello", results = {
- public String execute() throws Exception {
- // TODO Auto-generated method stub
- System.out.println("biz:"+this.biz.hashCode());
- User u=biz.login(this.getUser());
- if(u!=
- return SUCCESS;
- }
- return INPUT;
- }
- }