Skip to content
Advertisement

What is the default package name for Struts in 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?

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>

Advertisement

Answer

The package name is completely independent of your code artifacts.

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.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement