struts2动态调用,求大神支招
以下是我的代码
1.前台是Ext3.4,URL是这样写的吧?
Ext.Ajax.request({
method:"post",
url:"node!save",
success:function(r) {
var msg = r.responseText;
Ext.Msg.show({
title:"提示",
msg:msg
});
},
2.struts-node.xml配置如下
<package name="node" extends="ssh-default" namespace="/">
<action name="node" class="com.centersoft.Test001.web.action.UpdateOrSaveDeptAction" />
</package>
3.后台action代码如下
public class UpdateOrSaveDeptAction extends BaseAction{
public void save(){
System.out.println("saveEmp");
//println("OKOKOK");
}
}
启动tomcat服务器后,访问上面那个url地址,后台没有打印。。。。(估计是url地址写错了,求大神帮小弟解决下!!!!!!!!!!!!)
下面是web.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<filter>
<filter-name>struts</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,config/struts/struts.xml</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 添加spring监听器 -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:config/spring/applicationContext.xml
</param-value>
</context-param>
</web-app>
------解决方案--------------------调试看看你请求到后台的url是什么,相应调整js 代码
是不是包相对路径问题啊,
------解决方案--------------------struts配置文件内加上<constant name="struts.enable.DynamicMethodInvocation" value="true" />
------解决方案-------------------- url:"/node!save.action",