Based on Struts2 value (143 Roccaipo)

Source: Internet
Author: User

STRUTS2: Implementing the C (servlet) layer and V (JSP) layer
To add struts to your project:
1: Click on Project Right click to select MyEclipse
2: Select Add Struts capadilities
3: Select 2.1
1. Build a package in SRC, create a new class in the package and inherit the Actionsupport interface, and rewrite the Execute () method inside.
The code is: public class Actmnt extends Actionsupport {

private String name;

Public String GetName () {
return name;
}

public void SetName (String name) {
THIS.name = name;
}

@Override
Public String Execute () throws Exception {
TODO auto-generated Method Stub
return "name";
}
}
2. Create a new action in Struts.xml
<package name= "Default" extends= "Struts-default" >
<action name= "Userlogin" class= "Org.vo.Actmnt" >
<result name= "Name" >/stuer/bean.jsp</result>
</action>
</package>
3. Edit the display interface in the JSP
<s:bean name= "org.vo.Actmnt" id= "Stu" >
The:<br> can be output directly inside the bean tag
<s:param name= "name" > Zhou Ho Jun </s:param>
(1) The first method of assignment:
<s:property value= "Name"/><br>
(2) The second method of assignment:
<!--This method assigns a value string to the parameter must be quoted--and
<s:param name= "name" value= "' Zhou Ho Jun '" ></s:param>
<s:property value= "Name"/>
</s:bean>
<br>
Take the ID value outside the bean label:
<s:property value= "#stu. Name"/>
4. Deploy the project and enter: Http://localhost:8080/classwork/userlogin.action run in the browser.
The result is:

Based on Struts2 value (143 Roccaipo)

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.