zoukankan      html  css  js  c++  java
  • struts2Action的属性注入值

    类:

    package control.center;

    import java.net.URLEncoder;

    public class HelloWordAction {

     private String savePath;
     
     public String getSavePath() {
      return savePath;
     }
     public void setSavePath(String savePath) {
      this.savePath = savePath;
     }
     public String execute() throws Exception{
      URLEncoder.encode("星期三","UTF-8");
      return "hello word!";
     }
     
    }

    Action配置:

    <action name="hello" class="control.center.HelloWordAction" method="execute">
                 <param name="savepath">/images</param>
                 <param name="success">/WEB-INF/page/message.jsp</param>

    </action>

    将路径注入到类的savepath属性中。

    在页面上使用:

    ${savePath}得到savePath的值

    访问Action的默认后缀是.action,可以通过struts.action.extenstion修改默认后缀

    ,在struts配置中使用配置节点:<constant name="struts.action.extension" value="do"/>

    此配置将.action修改为.do

  • 相关阅读:
    单调队列+二分 G
    dp cf 1700 最近几天的刷题
    dp 20190618
    dp 20190617
    dp cf 20190615
    dp cf 20190614
    powercli
    zabbix docker-weixin
    cenetos-大文件排序
    esxcli命令
  • 原文地址:https://www.cnblogs.com/jinzhengquan/p/1963208.html
Copyright © 2011-2022 走看看