铝板价格行情:jquery+json+ajax二级分类

来源:百度文库 编辑:九乡新闻网 时间:2024/04/25 10:28:04
配置文件manager-config.xml:
 
               
       

 
----------------------------------------java类:@SuppressWarnings("serial")
@Scope("prototype")
@Controller("com.cms.action.manager.sys.ajax")
public class ColorAjax extends ajax_baseImp{
private transient int cate_id;
@Autowired
private color_Server base;public void getcolor(){
 Object temp=base.HqlExecute("from fwe_color where cate_id=:cate_id",new SqlOrHqlParameter("cate_id",cate_id));
 JSONArray jsonArray=JSONArray.fromObject(temp);
 super.renderHtml(jsonArray.toString());
}public int getCate_id() {
 return cate_id;
}public void setCate_id(int cate_id) {
 this.cate_id = cate_id;
}}-----------------------------
import org.springframework.beans.factory.annotation.Autowired;
import com.cms.base.structs2.ContextPvd;@SuppressWarnings("unchecked")
public class  ajax_baseImp extends ActionOutString implements java.io.Serializable{
 private static final long serialVersionUID = 5637966337178063634L;
 
 @Autowired
 protected ContextPvd contextPvd; 
 } -------------------------------------import java.io.IOException;import javax.servlet.http.HttpServletResponse;import org.apache.struts2.ServletActionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;import com.opensymphony.xwork2.ActionSupport;public class ActionOutString extends ActionSupport implements java.io.Serializable{ private static final long serialVersionUID = -1197476918924605433L;
 private static final Logger log = LoggerFactory
 .getLogger(ActionOutString.class);
 
 /**
  * 绕过Template,直接输出内容的简便函数.
  */
 
 protected String render(String text, String contentType) {
  try {
   HttpServletResponse response = ServletActionContext.getResponse();
   response.setContentType(contentType);
   response.getWriter().write(text);
  } catch (IOException e) {
   log.error(e.getMessage(), e);
  }
  return null;
 }
 
 /**
  * 直接输出字符串.
  */
 protected String renderText(String text) {
  return render(text, "text/plain;charset=UTF-8");
 } /**
  * 直接输出HTML.
  */
 protected String renderHtml(String html) {
  return render(html, "text/html;charset=UTF-8");
 } /**
  * 直接输出XML.
  */
 protected String renderXML(String xml) {
  return render(xml, "text/xml;charset=UTF-8");
 }
 
} 页面: