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
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.