Java advanced: Struts multi-module skills

Source: Internet
Author: User

Source: Internet

When using multiple struts modules, find some tips and experience to share with you.

You don't need to talk about the configuration of multiple modules. You only need to use different configurations,
Struts-config.xml as the default module, struts-config-module.xml as the/module configuration

There are many related instructions on CSDN.

The module in struts is actually similar to the subdirectory in the development of web programs on weekdays.
For example

/-Root
/Music
/Module
/...

For example, the above/music is used as the module name.
All paths in struts-config-music are/music/xxx. do by default.

In some tutorials, it is a good method to put jsp pages into/web-inf,
I did the same in the first place. Unfortunately, the struts action tag does not support contextRelative and only supports forward.
Therefore, it is not feasible to use/xxx. do to directly redirect or forward to a page.
They cannot be found because their addresses are relative to/music/web-inf/xxx. jsp.

My suggestion is that the directory under root should be consistent with the module.
For example

/
/ModuleA
/ModuleB

Although the security is somewhat reduced, it is very convenient to use.

Generally, you can use

<Html: link action = "/module/action">

The advantage is that the built-in support module does not need to write. do by yourself, which can make your. do
Any modification to another option does not affect the program running. For example, in jspa, pretend to be webwork.

The default On this page, all links are converted to relative/module. For example,

What should I do if I want to execute the action of the default module? Hey, it's actually very simple. At the beginning, I racked my brains and used switchAction to solve/module/switch? Prefix = & page =/xxx. do &... too much trouble

In fact, a traditional solution can be effectively solved. That is, You can return to the module on the previous layer. I did not expect it at the beginning.

Link labels have three different link Methods: page, href, and action.
Action points to a path by default, and page points to a jsp page, which can be used to write an external url relative to the href of the module.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.