What is the default package name for Struts in struts.xml?(struts.xml 中 Struts 的默认包名是什么?)
问题描述
我创建了一个名为 RegesterAction 的新类,但我没有将这个类保存在任何包中.如何在 struts.xml 中配置这个类?
I created a new class called RegesterAction but I didn't keep this class in any package. How can I configure this class in the struts.xml?
下面是 struts.xml 文件,但我无法理解属性值 default" 和 struts-default.
Below is the struts.xml file but I'm unable to understand the attribute values "default" and struts-default.
<struts>
<package name="default" extends="struts-default">
<action name="*Register" method="{1}" class="RegisterAction">
<result name="populate">/register.jsp</result>
</package>
</struts>
推荐答案
包名完全独立于您的代码工件.
The package name is completely independent of your code artifacts.
struts-default 包是... Struts 2 默认包.它定义了默认结果类型、拦截器、拦截器堆栈和其他一些默认值.您不需要扩展它,但如果你不这样做,你需要做大量的手动工作在你自己的包里.
The struts-default package is... the Struts 2 default package. It defines default result types, interceptors, interceptor stacks, and a few other defaults.. You do not need to extend it, but if you don't, you have a fair amount of manual work to do in your own package.
我相信你应该将你的动作类放在一个包中,并且想不出任何合理的论据来反对这样做的最佳实践.同样,您的操作类包完全独立于包名称或包扩展的内容(如果有).
I believe you should put your action classes in a package, and can think of no reasonable argument against the best practice of doing so. Again, your action class packages are completely independent of package names, or what (if any) the package extends.
这篇关于struts.xml 中 Struts 的默认包名是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:struts.xml 中 Struts 的默认包名是什么?
基础教程推荐
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- Struts2 URL 无法访问 2022-01-01
