Struts2 Namespace_ Namespace

Source: Internet
Author: User

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

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.