action获取不到参数

二号铺 发布于 2013/08/04 13:08
阅读 524
收藏 0
项目是有webservice,tiles,ajaxanywhere,struts2,ibties,spring等

web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>myorder</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>/axis2-web/index.jsp</welcome-file>
</welcome-file-list>

<!-- ajaxAnywhere -->
<filter>
<filter-name>AjaxAnywhere</filter-name>
<filter-class>org.ajaxanywhere.AAFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AjaxAnywhere</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>

<!--tiles监听器 -->
<listener>
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
<context-param>
<param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/config/tiles/tiles.xml</param-value>
</context-param>

<!-- spring监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:com/uu/configs/spring/ssh.xml</param-value>
</context-param>

<!--axis2 -->
<servlet>
<display-name>Apache-Axis Servlet</display-name>
<servlet-name>AxisServlet</servlet-name>
<servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/servlet/AxisServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>*.jws</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<servlet>
<display-name>Apache-Axis Admin Servlet Web Admin</display-name>
<servlet-name>AxisAdminServlet</servlet-name>
<servlet-class>org.apache.axis2.transport.http.AxisAdminServlet</servlet-class>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AxisAdminServlet</servlet-name>
<url-pattern>/axis2-admin/*</url-pattern>
</servlet-mapping>
<servlet>
<display-name>Axis Admin Servlet</display-name>
<servlet-name>AdminServlet</servlet-name>
<servlet-class>org.apache.axis.transport.http.AdminServlet</servlet-class>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AdminServlet</servlet-name>
<url-pattern>/servlet/AdminServlet</url-pattern>
</servlet-mapping>

<!-- struts2 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>struts-default.xml,struts-plugin.xml,/com/uu/configs/struts/struts.xml</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

struts.xml:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
    "http://struts.apache.org/dtds/struts-2.1.7.dtd">
<struts>
 <constant name="struts.i18n.encoding" value="utf-8" />
 <constant name="struts.ui.theme" value="simple"/>
 <constant name="struts.devMode" value="true"/>
 <constant name="struts.configuration.xml.reload" value="true"/>
 <constant name="struts.serve.static.browserCache" value="false"/>
 <constant name="struts.objectFactory" value="spring"/>
 <constant name="struts.multipart.maxSize" value="10485760"/>
 <constant name="struts.devMode" value="true"/>
 <constant name="struts.multipart.saveDir" value="/tmp"/>
 <constant name="struts.action.extension" value="do,ajax"/>
<package name="basepackage" extends="json-default" >
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<action name="jump" class="common">
<result name="success" type="tiles">jump</result>
</action>
<action name="changelanguage" class="common" method="changelanguage">
<result name="success"></result>
</action>
<action name="searchAllMenu" class="common" method="searchAllMenu">
<result name="toMenuList" type="tiles">menuList</result>
</action>
<action name="updateMenu" class="common" method="updateMenu">
<result name="success" type="tiles">editMenu</result>
</action>
</package>
</struts>

action的一个方法(就是这个方法不能过的参数menuId)我的类是继承了actionsupport的:
public String updateMenu() {
HttpServletRequest req = ServletActionContext.getRequest();
System.out.println("-----------");
String menuId = req.getParameter("menuId");
System.out.println(menuId);
try {
PrintWriter pw = response.getWriter();
pw.print("error");
} catch (Exception e) {
e.printStackTrace();
}
return "success";
}

页面js:
<script type="text/javascript">
function updateAction(menuId) {
document.menuListForm.action="${pageContext.request.contextPath}/updateMenu.do?menuId="+menuId;
document.menuListForm.submit();
}
</script>

通过这个js方法,我实在不知道为什么action中的那个方法获取不到menuId 

打印的定西就是这个:
-----------
null
null
加载中
返回顶部
顶部