Java Advanced: Struts multi-module techniques _java Programming

Source: Internet
Author: User
Article Source: Internet

In the use of struts multiple modules, find some tips and experience to share with you.

The configuration of multiple module is not said, just use a different config,
Struts-config.xml as the default module, Struts-config-module.xml as/module configuration

There are a lot of csdn on the show.

The module in struts is actually similar to a subdirectory in the development Web program on weekdays
Such as


/-Root
/music
/module
/...



For example, the above/music as a module name
Then all path defaults in Struts-config-music are/music/xxx.do

Some tutorials say it's a good way to put JSP pages into/web-inf,
I did it at first, too, but struts ' action tag does not support contextrelative, only forward support
Therefore, if you want to use/xxx.do Direct Redirect or forward to a page is not feasible.
Because their address is not the same as the/music/web-inf/xxx.jsp.

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


/
/modulea
/moduleb


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

In general, to write a link, you can write by




His advantage is the built-in support module, which does not need to be written by itself. Do, which can make your. do
Any modification to the other without affecting the operation of the program. For example,. Jspa, pretend webwork.

The default In this page, all link is converted to/module such as

So what if you want to perform the default module action? Hey, actually very simple. I began to rack my brains, using the switchaction to solve the/module/switch?prefix=&page=/xxx.do& Much trouble

In fact, a traditional approach can be effectively addressed. namely You can go back to the module in the previous layer. I couldn't have imagined it at first.

The

  LINK tag has page,href,action three different linking methods.
  where the action defaults to a path,page point to a JSP page, and also to an href that is relative to module to write an external URL.

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.