Getting started with struts2 instance code backup

Source: Internet
Author: User

Package action;
 
Import com. opensymphony. xwork2.ActionSupport;
 
Public class FirstAction extends ActionSupport
{
/**
*
*/
Private static final long serialVersionUID = 1L;
Private int operand1;
Private int operand2;
 
Public String execute () throws Exception
{
If (getSum ()> = 0) // if the number of codes and non-negative integers, jump to the positive. jsp page
{
Return "positive ";
}
Else // if the number of codes and values are negative integers, jump to the negative. jsp page.
{
Return "negative ";
}
}
 
Public int getOperand1 ()
{
Return operand1;
}
 
Public void setOperand1 (int operand1)
{
System. out. println (operand1 );
This. operand1 = operand1;
}
 
Public int getOperand2 ()
{
Return operand2;
}
Public void setOperand2 (int operand2)
{
System. out. println (operand2 );
This. operand2 = operand2;
}
Public int getSum ()
{
Return operand1 + operand2; // calculate the number of codes of two integers and
}
}


 

<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE struts PUBLIC "-// Apache Software Foundation // DTD Struts Configuration 2.1 // EN"
Http://struts.apache.org/dtds/struts-2.1.dtd>
<Struts>
<Package name = "default" namespace = "/" extends = "struts-default">

<Action name = "sum" class = "action. FirstAction">
<Result name = "positive">/positive. jsp </result>
<Result name = "negative">/negative. jsp </result>
</Action>
</Package>

</Struts>


 

 

<? Xml version = "1.0" encoding = "UTF-8"?>
<Beans
Xmlns = "http://www.springframework.org/schema/beans"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xmlns: p = "http://www.springframework.org/schema/p"
Xsi: schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">


</Beans>

 

 

<? Xml version = "1.0" encoding = "UTF-8"?>
<Web-app version = "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>
 


<Welcome-file-list>
<Welcome-file> sum. jsp </welcome-file>
</Welcome-file-list>
 
 
<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-pattern>/* </url-pattern>
</Filter-mapping>
 
 
 
</Web-app>


 

<% @ Page language = "java" import = "java. util. *" pageEncoding = "GBK" %>
<% @ Taglib prefix = "s" uri = "/struts-tags" %>

<%
String path = request. getContextPath ();
String basePath = request. getScheme () + ": //" + request. getServerName () + ":" + request. getServerPort () + path + "/";
%>

<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<Html>
<Head>
<Base href = "<% = basePath %>">

<Title> My JSP 'Negative. jsp 'starting page </title>

<Meta http-equiv = "pragma" content = "no-cache">
<Meta http-equiv = "cache-control" content = "no-cache">
<Meta http-equiv = "expires" content = "0">
<Meta http-equiv = "keywords" content = "keyword1, keyword2, keyword3">
<Meta http-equiv = "description" content = "This is my page">
<! --
<Link rel = "stylesheet" type = "text/css" href = "styles.css">
-->

</Head>
 
<Body>
Algebra and negative integer
</Body>

</Html>


 

 

<% @ Page language = "java" import = "java. util. *" pageEncoding = "GBK" %>
<% @ Taglib prefix = "s" uri = "/struts-tags" %>

<%
String path = request. getContextPath ();
String basePath = request. getScheme () + ": //" + request. getServerName () + ":" + request. getServerPort () + path + "/";
%>

<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<Html>
<Head>
<Base href = "<% = basePath %>">

<Title> My JSP 'positive. jsp 'starting page </title>

<Meta http-equiv = "pragma" content = "no-cache">
<Meta http-equiv = "cache-control" content = "no-cache">
<Meta http-equiv = "expires" content = "0">
<Meta http-equiv = "keywords" content = "keyword1, keyword2, keyword3">
<Meta http-equiv = "description" content = "This is my page">
<! --
<Link rel = "stylesheet" type = "text/css" href = "styles.css">
-->

</Head>
 
<Body>
Algebra and non-negative integer </Body>

</Html>


 

<% @ Page language = "java" import = "java. util. *" pageEncoding = "GBK" %>
<% @ Taglib prefix = "s" uri = "/struts-tags" %>

<%
String path = request. getContextPath ();
String basePath = request. getScheme () + ": //" + request. getServerName () + ":" + request. getServerPort () + path + "/";
%>

<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<Html>
<Head>
<Base href = "<% = basePath %>">

<Title> My JSP 'sum. jsp 'starting page </title>

<Meta http-equiv = "pragma" content = "no-cache">
<Meta http-equiv = "cache-control" content = "no-cache">
<Meta http-equiv = "expires" content = "0">
<Meta http-equiv = "keywords" content = "keyword1, keyword2, keyword3">
<Meta http-equiv = "description" content = "This is my page">
<! --
<Link rel = "stylesheet" type = "text/css" href = "styles.css">
-->

</Head>
 
<Body>
Algebra and
<Br/>
<S: form action = "sum. action">
<S: textfield name = "operand1" label = "operand 1"/>
<S: textfield name = "operand2" label = "operand 2"/>
<S: submit value = "sum"/>
</S: form>
</Body>

</Html>

Struts2 related jar

 

 

 

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.