struts1跳入指定方法

1 主页面调用

  $.ajax({  
   <a target=_blank href="'<%=contextPath%>/cap/mainPage/updateTreeInfo.do?method=updateTree">url:"<%=contextPath%>/cap/mainPage/updateTreeInfo.do?method=updateTree</a>",  
  data:{inputValue:info},  
   dataType:"json",
 success:function(result){  
alert("success");
   }  
 });  


2 java 类

package com.hm.web.mainPage.action;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

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

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;





public class UpdateMainPageTree extends DispatchAction{

	/*
	 * 更新主页面树信息
	 * */
	public void updateTree(ActionMapping mapping,ActionForm form,HttpServletRequest request, HttpServletResponse response){
		String inputValue = request.getParameter("inputValue");
		try {
			inputValue = URLDecoder.decode(inputValue, "UTF-8");
			System.out.println("inputValue3 = " + inputValue);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}

	}
}


3 spring配置文件

 <!-- 更新主页面树信息 -->
   <bean name="/cap/mainPage/updateTreeInfo" class="com.hm.web.mainPage.action.UpdateMainPageTree" autowire="byType" />


 

4 struts1 文件配置

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
          "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
    <form-beans>
   	 <!-- 上传excel的formBean -->
	    <form-bean name="uploadform" type="com.hm.web.excel.upload.entity.ExcelUploadForm"></form-bean>
   </form-beans>
   <action-mappings>
       
   <!-- 更新主页面树信息配置开始 -->
        <action 
            path="/cap/mainPage/updateTreeInfo"
           	type="org.springframework.web.struts.DelegatingActionProxy"
            scope="request" validate="false"  parameter="method"
            >
            <forward name="result"  path="/Module/cap/device/CapDeviceIndex.jsp"></forward>  
        </action>
    <!-- 更新主页面树信息配置结束 -->    
   </action-mappings>
</struts-config>


 

 

你可能感兴趣的:(struts1跳入指定方法)