The namespace determines the access path to the action, which defaults to "", which can accept action for all paths
Namespace can be written as/, or/xxx, or/XXX/YYY, the corresponding action access path is/index.action,/xxx/index.action, or/xxx/yyy/index.action
Namespace it is best to also use a module to name
1. New Project Web Project:struts2_namespace
2. Introduction of the Struts2 jar package
3.Struts.xml
Code:
1<?xml version= "1.0" encoding= "UTF-8"?>2<!DOCTYPE Struts public3"-//apache software foundation//dtd Struts Configuration 2.0//en"4"Http://struts.apache.org/dtds/struts-2.0.dtd" >5 6<struts>7<!--8<constant name= "Struts.enable.DynamicMethodInvocation" value= "false"/>9 Ten One<include file= "Example.xml"/> A - - the< PackageName= "Default" namespace= "/"extends= "Struts-default" > -<default-action-ref name= "index"/> -<action name= "Index" > -<result type= "Redirectaction" > +<param name= "ActionName" >HelloWorld</param> -<param name= "namespace" >/example</param> +</result> A</action> at</ Package> -- -<!--ADD packages here-- -<constant name= "Struts.devmode" value= "true"/> -< PackageName= "Front"extends= "Struts-default" namespace= "/front" > -<action name= "Index" > in<result>/Namespace.jsp</result> -</action> to</ Package> + -< PackageName= "Main"extends= "Struts-default" namespace= "" > the<action name= "Index" > *<result>/Namespace.jsp</result> $</action>Panax Notoginseng</ Package> - the</struts>
Struts.xml
===========================================================================
Annotations:
Package: A case for distinguishing between duplicate names
Namespace: Must start with "/", such as:/front, in the URL we will enter: Http://localost:1000/struts2_0200_Namespace/front/index.action
The package and namespace are named in the module when they are developed.
Result: All Name= "Success" of the result, can not write: Name= "Success" that is:<result>/namespace.jsp</result>
============================================================================
4. namespace.jsp
Code:
<?xml version= "1.0" encoding= "UTF-8"?>
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "
pageencoding= "UTF-8"%>
<% @taglib uri= "/struts-tags" prefix= "s"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title>insert title here</title>
<body>
namespace determines the access path of the action, which defaults to "", which can receive action<br of all paths/>
Namespace can be written as/, or/xxx, or/XXX/YYY, the corresponding action access path is/index.action,
/xxx/index.action, or/xxx/yyy/index.action.<br/>.
Namespace it is best to also use a module to name
</body>
Struts2 Namespace_ Namespace