Struts in the use of multi-module, and find tips and experiences to share with you.
On multi-module configuration is not to say, just use a different config,
struts-config.xml as the default module, struts-config-module.xml as / module configuration
CSDN there are many related instructions.
struts in the module, in effect, similar to the usual procedure in a subdirectory of web development
If
/ - Root
/ Music
/ Module
/ ...
For example, the above / music as a module name
Then the struts-config-music all of the default path is / music / xxx.do
Some tutorial jsp page saying we should put / web-inf, this is a good way
At first I do the same, unfortunately, struts in action labels do not support contextRelative, only the forward support
So, if you want to use / xxx.do redirect or forward directly to a page will not work.
Because they address relative to the / music / web-inf / xxx.jsp so can not find it.
My advice is, root and the following module to the same directory.
For example,
/
/ ModuleA
/ ModuleB
Although some of the security reduced, but very convenient to use.
In general, write a link, you can write
He has the advantage of built-in support module, do not need to write your own. Do, which can make you. Do
Any changes to the other without affecting the program is running.For example,. Jspa, pretend webwork
The default is relatively module
On this page, all the link are converted to relative to / module, such as
So, if the default module to perform the action how to do?Hey, is actually very simple.When I started, brains, using a switchAction to address / module / switch? Prefix = & page = / xxx.do &.... much trouble
In fact, a traditional way to solve.That
The module can return in a layer.I began to really did not expect.
link labels page, href, action links to three different methods.
Which, action point to a default path, page point to a jsp page, the href is relative to the module can write an external url.