Struts multi-module skills

zhaozj2021-02-11  258

In the use of Struts multi-module, find some tips and experience, share it with you.

With regard to multi-module configuration, just use different config, struts-config.xml as the default module, struts-config-module.xml as / module configuration

There are many related descriptions on 9CBS.

Module in Struts, in fact, similar to subdirectory in the development of Web programs in the weekday, such as /-root / music / module / ..., the above / MUSIC is used as the module name, then all PATH defaults in Struts-Config-Music /Music/xxx.do

Some tutorials say to put JSP pages in / web-inf, this is a good way, I do this, but unfortunately, Struts's Action tag does not support ContextRelative, only Forward support, if you want to use / xxx .do directly redirect or forward to a page is not going. Because their address is not found relative to /music/web-inf/xxx.jsp.

My suggestion is that the directory below root is consistent with Module. For example / / modulea / moduleb

Although safety is slightly lowered, it is very convenient to use.

General, to write a link, you can write , his benefit is built-in supporting Module, you don't need to write .do, this can make Your .do arbitrarily modifications are other without affecting the program. For example, .jspa, pretend to Webwork

The default is relative to Module. For example, the page that enters / module / Actiona points in this page, all LINK is converted to relative to / module as , actually / module / Actionb

So what should I do if I want to execute the default module? Oh, it is actually very simple. I started to start my brain, using SwitchAction to solve /Module/switch?prefix=&page=/xxx.do & ....

In fact, a traditional approach can be effectively solved. That is, You can return to the Module of the previous layer. I really didn't think it was.

The LINK label has three different link methods of Page, HREF, Action. Among them, the Action default points to a PATH, point points to a JSP page, and is also written to the external URL with respect to the Module's HREF.

Copyright Notice: This article is completed by ice cloud, the author retains Chinese copyright. No commercial use is not permitted without permission. Welcome to the reprint, but please keep the article and copyright statement complete. For contact, please send an email: Icecloud (at) sina.comblog: http: //icecloud.51.net

转载请注明原文地址:https://www.9cbs.com/read-4937.html

New Post(0)