自学SSH框架时编写的小案例。之前都是基于xml配置文件配置的。今天改为注解配置。就一直出错。
出错前忘记加@Scope("prototype"),程序运行过程中会有如下错误
Struts Problem Report
Struts has detected an unhandled exception:
Messages: could not initialize proxy - no Session
could not initialize proxy - no Session - Class: org.hibernate.proxy.AbstractLazyInitializer File: AbstractLazyInitializer.java Method: initialize Line: 164 - org/hibernate/proxy/AbstractLazyInitializer.java:164:-1
File: org/hibernate/proxy/AbstractLazyInitializer.java
Line number:
解决办法如下:
package com.zjft.actions;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.Map;
import javax.annotation.Resource;
import org.apache.struts2.interceptor.RequestAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;
import com.zjft.entities.Employee;
import com.zjft.service.DepartmentService;
import com.zjft.service.EmployeeService;
@Controller("employeeAction")
@Scope("prototype")
public class EmployeeAction extends ActionSupport implements RequestAware,ModelDriven<Employee>,Preparable {
private static final long serialVersionUID = 1L;}