📄 tryajaxaction.java
字号:
package sealink.com.ajax.action;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.apache.struts.taglib.bean.StrutsTag;
import org.apache.struts.util.LabelValueBean;
import org.w3c.dom.Document;
import com.sdicons.json.model.JSONObject;
import com.struts.converters.ConvertScriptObj;
import com.struts.converters.StrutsAjaxParam;
import com.wutka.jox.JOXBeanDOM;
import com.wutka.jox.JOXBeanWriter;
import sealink.com.ajax.dto.TryAjaxAdditional;
import sealink.com.ajax.form.TryAjaxForm;
public class TryAjaxAction extends DispatchAction{
public ActionForward showTryAjaxDef(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
//remember for sake of this example our form has Session scope
return (mapping.findForward("TryAjax"));
}
public ActionForward doAjax(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
//remember for sake of this example our form has Session scope
// String sName = request.getParameter("name");
TryAjaxForm tf = (TryAjaxForm)form;
tf.setValue(tf.getValue()+"test");
ConvertScriptObj cso = new ConvertScriptObj();
cso.add(new StrutsAjaxParam("TryAjaxForm",tf));
List lis = new ArrayList();
lis.add(new LabelValueBean("a","a"));
lis.add(new LabelValueBean("b","b"));
lis.add(new LabelValueBean("c","c"));
lis.add(new LabelValueBean("e","e"));
//cso.add(new StrutsAjaxParam("name",lis));
response.setContentType("text/xml");
String sRt = cso.parse();
response.getWriter().print(sRt);
return null;
}
private String getTestData(){
String sTemp = null;
sTemp = "{name:'name',value:'xt'}";
return sTemp;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -