@JSON(serialize=false) public MenuitemService<MenuitemDao, Menuitem> getMenuitemService() { 懒加载问题
package com.tfy.oa.action;
import java.util.Collection;
import java.util.Set;
import javax.annotation.Resource;
import com.tfy.oa.Util.BaseAction;
import com.tfy.oa.dao.MenuitemDao;
import com.tfy.oa.domain.Menuitem;
import com.tfy.oa.domain.User;
import com.tfy.oa.service.MenuitemService;
import org.apache.struts2.json.JSONInterceptor;
import org.apache.struts2.json.JSONResult;
import org.apache.struts2.json.annotations.JSON;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
@Controller("menuitemAction")
@Scope("prototype")
public class MenuitemAction extends BaseAction<Menuitem>{
@Resource(name="menuitemService")
private MenuitemService<MenuitemDao, Menuitem> menuitemService;
private Collection<Menuitem> menuitemList;
@JSON(serialize=false)
public MenuitemService<MenuitemDao, Menuitem> getMenuitemService() {
return menuitemService;
}
public void setMenuitemService(
MenuitemService<MenuitemDao, Menuitem> menuitemService) {
this.menuitemService = menuitemService;
}
public Collection<Menuitem> getMenuitemList() {
return menuitemList;
}
public void setMenuitemList(Collection<Menuitem> menuitemList) {
this.menuitemList = menuitemList;
}
public String showMenuitemsByUser(){
this.menuitemList=this.menuitemService.getMenuitemsByUser();
return SUCCESS;
}
public String showMenuitems(){
this.menuitemList=this.menuitemService.getAllMenuitems(null);
System.out.println("showMenuitems");
System.out.println(menuitemList);
return SUCCESS;
}
public String showMenuitemByPid(){
this.menuitemList=this.menuitemService.getMenuitemsByPid(this.getModel().getPid());
for(Menuitem menuitem:menuitemList){
Set<User> users=menuitem.getUsers();
for(User user:users){
user.setDepartment(null);
user.setPosts(null);
}
}
return SUCCESS;
}
}