Multiple profile Security Module partitioning

Source: Internet
Author: User

01: Guide Package Configuration Web. xml

<?xml version="1.0"encoding="UTF-8"? ><web-app version="2.4"xmlns="HTTP://JAVA.SUN.COM/XML/NS/J2EE"Xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation="HTTP://JAVA.SUN.COM/XML/NS/J2EEhttp//java.sun.com/xml/ns/j2ee/web-app_2_4.xsd "><!-- on: Start struts2 Frame-<filter> <filter-name>struts2</filter-name> <filter-class>Org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pat Tern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.jsp</we Lcome-file> </welcome-file-list></web-app>

02: Writing The Action class

 Packagecom.self.action;/*** 02: Write the corresponding processing method*/ Public classhelloworldaction {PrivateString message;  PublicString Dohelloworld () {return"Doresult"; }        //To inject a value into a property, you need to provide a set method     Public voidsetmessage (String message) { This. Message =message; }    //Show values on page, need get method     PublicString getMessage () {returnmessage; }}

03: Configure Struts.xml

<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE struts public    "-//apache software foundation//dtd struts Configuration 2.0//en"    "/http Struts.apache.org/dtds/struts-2.0.dtd "><struts><!--01: Change. Action access to. Do--><constant name=" Struts.action.extension "value=" do ></constant><!--02: Specify the default encoding, Equivalent to HttpServletRequest's Setcharacterencoding method, also used for freemarker, velocity output--><constant name= " Struts.i18n.encoding "value=" UTF-8 "></constant><include file=" Department.xml "/><include file=" Employ.xml "/></struts>

  

04: Writing Department.xml

<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE struts public    "-//apache software foundation//dtd struts Configuration 2.0//en"    "/http Struts.apache.org/dtds/struts-2.0.dtd "><struts><package name=" dep "namespace="/department "extends=" Struts-default "><action name=" HelloWorld "class=" com.self.action.HelloWorldAction "method=" Dohelloworld " ><param name= "message" >department</param><result name= "Doresult" >/showresult.jsp</result ></action></package></struts>

  

  

05: Writing Employ.xml

<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE struts public    "-//apache software foundation//dtd struts Configuration 2.0//en"    namespace= "employ " extends=" Struts-default "><action name=" HelloWorld "class=" Com.self.action.HelloWorldAction "method=" Dohelloworld "><param name=" message ">employ</param><result name=" Doresult ">/showresult.jsp </result></action></package></struts>

  

06: Writing the page

<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%>

  

07: Access Path 1

Show Results 1:employ

08: Access Path 2

Show Results 2:department

Multiple profile Security Module partitioning

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.