⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 extdemoaction.java

📁 ext示例
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.ext.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/** 
 * MyEclipse Struts
 * Creation date: 04-21-2008
 * 
 * XDoclet definition:
 * @struts.action validate="true"
 */
public class ExtDemoAction extends Action {
	/*
	 * Generated Methods
	 */

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		String start = request.getParameter("start");
	   	String limit = request.getParameter("limit");
	   	String sort = request.getParameter("sort");
	   	String dir = request.getParameter("dir");
	   	System.out.println("======>"+sort);
	   	if(dir == null){
	   		dir="ASC";
	   	}
	   	
	   	try{
	   		int index = Integer.parseInt(start);
	   		int pageSize = Integer.parseInt(limit);
	   		
	   		String json = "{totalProperty:100,root:[";
	   		if(dir.equals("ASC")){
	   			for(int i = index;i < pageSize+index;i++)
	   			{
	   				json+="{id:"+i+",STRENUMB:'STRENUMB"+i+"',STRENAME:'STRENAME"+i+"',STREWAY:'STREWAY"+i+"',STREMEMO:'STREMEMO"+i+"',Info:'Info"+i+"'}";
	   				if(i != pageSize+index-1){
	   					json+=",";
	   				}
	   			}
	   		}else{
	   			for(int i = pageSize+index;i>index;i--)
	   			{
	   				json+="{id:"+i+",STRENUMB:'STRENUMB"+i+"',STRENAME:'STRENAME"+i+"',STREWAY:'STREWAY"+i+"',STREMEMO:'STREMEMO"+i+"',Info:'Info"+i+"'}";
	   				if(i!=index-1){
	   					json+=",";
	   				}
	   			}
	   		}
	   		json+="]}";
	   		response.getWriter().write(json);
	   	}catch(Exception ex)
	   	{
	   		ex.printStackTrace();
	   	}
		return null;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -