What is a Namespace?
Namespace is "namespace", also known as "namespace", "namespace". A form of code organization used by various languages in VS.NET is classified by namespace, distinguishing different code functions is also part of the full name of all classes in VS.NET.
- name
- The so-called namespace refers to
- In struts2
- In struts2, namespace is a property in the package that is used to mark the access path of the action. Note: Only the namespace of the package can mark the path and not the name attribute. In struts2, there is a default namespace- "". If the package does not specify a namespace, the actions in the package use the default namespace. If the namespace is not specified when accessing the action, struts2 will first search for the action in the root namespace-"/", and then find the action in the default namespace. If it can't find it again, it will report an error, which means that struts2 will only find two layers of namespace.
- In XML
- Namespaces in XML provide a way to avoid element naming conflicts.
- Naming conflict
- in
- The C ++ language after 1998 provides a global namespace, which can avoid causing global naming conflicts. As an example, note the following two header files:
- // one.h
- char func (char);
- class String {...};
- // somelib.h
- class String {...};
- If defined as above, it is impossible for these two header files to be included in the same program, because the String class will conflict.
- The so-called namespace is a method of encapsulating the [2] library name. It is like setting up a fence in each library.
- Continue to demonstrate a complete namespace example here:
// DISPLAYNamespaceDemonstration #include <iostream> using namespace std; namespace savitch1 { void greeting (); } namespace savitch2 { void greeting (); } void big_greeting (); int main () { { using namespace savitch2; // Use savictch2, std, and global namespaces greeting (); } { using namespace savitch1; // Use savitch1, std, and global namespaces greeting (); } big_greeting (); // Used both std and global namespaces return0; } namespace savitch1 { void greeting () { cout << "Hellofromnamespacesavitch1. \ n"; } } namespace savitch2 { void greeting () { cout << "Greetingsfromnamespacesavitch2. \ n"; } } void big_greeting () { cout << "ABigGlobalHello! \ n"; }