嗨,我想使用 jquery ajax 调用 struts2 操作,我只能使用 ajax 调用 Servlet。请任何人帮助。这是我的代码:
我的 struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="view" extends="struts-portlet-default"
namespace="/view">
<action name="bcmPMPF"
class="com.ibm.pm.action.PMPeriodicAction" method="prepare">
<result name="success">/_JQGridPorletCrudColumns/jsp/html
/JQGridPorletCrudColumnsPortletView.jsp</result>
</action>
<action name="bcmPMPFC.action"
class="com.ibm.pm.action.PMPeriodicColumnAction" method="prepare">
<result name="success">/_JQGridPorletCrudColumns/jsp/html
/JQGridPorletCrudColumnsPortletView.jsp</result>
</action>
</package>
</struts>
and my jsp page is:
<SCRIPT LANGUAGE="JavaScript">
var colModel;
var colNames;
var
urlPath='<%=renderResponse.encodeURL(renderRequest.getContextPath())%>'+"/BCMRoleInstanceServlet";
var urlColPath='<%=renderResponse.encodeURL(renderRequest.getContextPath())%>'+'/view/bcmPMPFC';
$(document).ready(function(){
$("#srid").live('change',(function(event){
$.ajax(
{
type: "POST",
url: urlColPath,
data: "",
dataType: 'json',
success: function(result)
{
alert("result:"+result);
}
});
}));