我是Struts框架的新手。我正在努力理解动作映射是如何准确地工作的。假设我有一个发送AJAX请求的JavaScript文件:
$("button").click(function(){
$.ajax({url: "myTestUrl.do", success: function(result){
//do something with result
});
});我的struts-config.xml文件如下所示:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<form-beans>
<form-bean name="testForm" type="com.test.TestForm"/>
</form-beans>
<!-- Global Forwards -->
<global-forwards>
</global-forwards>
<!-- Action Mappings -->
<action-mappings>
<action path="/myTestUrl"
type="com.test.TestAction"
name="testForm"
scope="request" />
</action-mappings>
<controller locale="true"/>
</struts-config>我不明白action和form-bean之间的关系。我的请求会被TestAction处理吗?如果是这样,表单bean type属性的目的是什么?
更新
对于任何需要struts框架的人来说,请查看这链接。
发布于 2016-04-06 18:59:42
该关系由动作配置中的name属性创建。因此,如果您使用name="testForm",那么名为testForm的form将被注入到操作的execute方法中。
如果相对url与操作配置中的路径值匹配,并且在servlet映射模式中将操作servlet映射到*.do,则可能会处理您的请求。
type属性用于输入<form-bean>类的FQCN,这可能会扩展ActionForm。Struts需要它能够在需要时实例化bean。
https://stackoverflow.com/questions/36458341
复制相似问题