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.

相关文章