zoukankan      html  css  js  c++  java
  • struts2的action编写

    例 HelloWorld.jsp

    
    <% @ page contentType = "text/html; charset=UTF-8 " %> 
    
    <% @ taglib prefix = "s" uri = "/struts-tags " %> 
    
    <html> 
    
    <head> 
    
        <title> Hello World! </title> 
    
    </head> 
    
    <body> 
    
        <h2><s:property value ="message"/></h2> 
    
    </body> 
    
    </html>
    

    例 classes/tutorial/HelloWorld.java

    
    import com.opensymphony.xwork2.ActionSupport;
    
    public class HelloWorld extends ActionSupport  {
    
        private String message ;
    
        public String getMessage()  {
    
            return message;
    
        } 
    
        public void tring setMessage(String message)  {
    
            this.message=message;
    
        }
    
        @Override 
    
        public String execute ()  {
    
            message = " Hello World, Now is " + DateFormat.getInstance().format( new Date());
    
            return success;
    
        } 
    
    }
    

    例 classes/struts.xml中HelloWorld Action的配置

    
    <package name ="ActionDemo" extends ="struts-default"> 
    
        <action name ="HelloWorld" class ="tutorial.HelloWorld"> 
    
            <result> /HelloWorld.jsp </result> 
    
        </action> 
    
    </package>
  • 相关阅读:
    chrome webkitappearance
    图片占用内存
    javascript性能优化repaint和reflow
    vim 系统剪切板
    CSS选择符的命名(转载)
    relative 内部 margin
    中国软件企业
    dom元素排序
    shell
    tips for asm
  • 原文地址:https://www.cnblogs.com/yuyu666/p/9795576.html
Copyright © 2011-2022 走看看