Getting Started with Java strtus2 dynamicmethodinvocation configuration

Source: Internet
Author: User

Here's how to use the STRTUS2 dynamic configuration.

After configuration, do not use <action method= "" > To configure the specific method of the call.

First: Web. xml

<?XML version= "1.0" encoding= "UTF-8"?><Web-appversion= "2.5"xmlns= "Http://java.sun.com/xml/ns/javaee"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">  <Display-name></Display-name>        <Filter>      <Filter-name>Struts2</Filter-name>      <!--can be found in Org.apache.struts2.dispatcher.ng.filter under the referenced jar package Struts2-core-2.3.15.3.jar -      <Filter-class>Org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</Filter-class>  </Filter>  <filter-mapping>      <Filter-name>Struts2</Filter-name>      <Url-pattern>/*</Url-pattern>  </filter-mapping>  </Web-app>

Second: Struts.xml

    < Packagename= "Menu"namespace= "/menu"extends= "Struts-default">       <Actionname= "MainPage"class= "Com.almostman.action.MainPageAction">         <resultname= "Success">/success.jsp</result>         <resultname= "Input">/input.jsp</result>       </Action>    </ Package> 

Third: Mainpageaction.java

 Packagecom.almostman.action;Importorg.apache.struts2.convention.annotation.Action;ImportOrg.apache.struts2.convention.annotation.Namespace;ImportOrg.apache.struts2.convention.annotation.ParentPackage;ImportOrg.apache.struts2.convention.annotation.Result;ImportCom.opensymphony.xwork2.ActionSupport; Public classMainpageactionextendsactionsupport{/**     *      */    Private Static Final LongSerialversionuid = 1L;  PublicString Add ()throwsException {if("admin". Equals (username) && "admin". Equals (password)) {            returnSUCCESS; }                returnINPUT; }        PrivateString username; PrivateString password;  PublicString GetUserName () {returnusername; }     Public voidSetusername (String username) { This. Username =username; }     PublicString GetPassword () {returnpassword; }     Public voidSetPassword (String password) { This. Password =password; }}

This allows you to configure the

Use link: http://localhost:8081/struts013/Menu/mainpage!add.action?username=admin&password=admin can see the effect.

Source: http://pan.baidu.com/s/1gfCX68r

Getting Started with Java strtus2 dynamicmethodinvocation configuration

Related Article

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.