gpt4 book ai didi

struts-1 - Struts struts-config.xml Action 映射解释

转载 作者:行者123 更新时间:2023-12-04 20:35:34 25 4
gpt4 key购买 nike

我是 Struts 框架的菜鸟。我试图了解 Action 映射是如何工作的。假设我有一个发送 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 MCV 框架的人,请查看 this关联。

最佳答案

该关系由 name 建立。 Action 配置中的属性。所以如果你使用 name="testForm"然后形成名称为 testForm 的 bean将被注入(inject)到 Action 的执行方法中。

如果相对 url 与操作配置中的路径值匹配并且您已将操作 servlet 映射到 *.do,则您的请求可能会被处理。在 servlet 映射模式中。
type <form-bean> 的属性用于输入可能会扩展 ActionForm 的 bean 类的 FQCN . Struts 需要它能够在需要时实例化 bean。

关于struts-1 - Struts struts-config.xml Action 映射解释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36458341/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com