jquery動態調用struts中的action – JAVA編程語言程序開發技術文章

———————————js部分—————————–
function checkDbdl(){
var bblx = document.getElementById("bblx").value;
var basePath = document.getElementById("basePath").value;
var dbdlxmlpath = document.getElementById("dbdlxmlpath").value;
var bbdl = document.getElementById("dbdl").value;
$.ajax({  
    url: basePath+'readXmlAction_getSmallTool.action',//調用的action  
    data: {'strXmlPath':dbdlxmlpath },//請求的參數  
    success:function(msg){  
         $("#dbxl").html(oop+msg);  
    }  
});    
}

—————————–java部分——————————
package com.cs.webTool.action;

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

import org.apache.struts2.ServletActionContext;

import com.cs.webTool.util.ReadXml;
import com.opensymphony.xwork2.ActionSupport;

public class ReadXmlAction extends ActionSupport {
public void readXml() throws Exception {

HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse res = ServletActionContext.getResponse();
String strXmlPath = request.getParameter("strXmlPath");

res.getWriter().print(msg);
}
}
————————–struts配置———————————
<action name="readXmlAction_*" class="com.cs.webTool.action.ReadXmlAction" method="{1}">
</action>

發佈留言