当前位置: 代码迷 >> Java Web开发 >> 关于struts2零配置的拦截器有关问题
  详细解决方案

关于struts2零配置的拦截器有关问题

热度:4069   发布时间:2013-02-25 21:10:32.0
求教:关于struts2零配置的拦截器问题!
package com.still.action.admin;

import java.io.IOException;
import java.io.PrintWriter;

//import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.convention.annotation.Action;

import com.still.action.BaseAction;

@Action(value="staff")
public class StaffAdmin extends BaseAction{

/**

*/
private static final long serialVersionUID = 1L;
private final String encoding = "GBK";

public String getStaff(){
try {
StaffAdmin.responseOut(encoding, "登录中...", this.getResponse());
System.out.println(this.getRequest().getParameter("str"));
} catch (Exception e) {
e.printStackTrace();
}
return null;
}

public Object getModel() {
return null;
}

public static void responseOut(String encoding, String data, HttpServletResponse response) {
response.setContentType("text/html; charset=" + encoding);
try {
PrintWriter pw = response.getWriter();
pw.print(data);
pw.close();
} catch (IOException e) {
e.printStackTrace();
}
}

}

注解方式实例化Action。

------解决方案--------------------------------------------------------
我也遇到了这样的问题
后来干脆用Filter了
------解决方案--------------------------------------------------------
web.xml里面配置了吗
  相关解决方案