zoukankan      html  css  js  c++  java
  • Struts2 为Action 的属性注入值&& 处理请求后缀

    在Struts2中的配置文件中,我们可以很方面的为Action中的属性注入值。注意:属性必须提供set()若在页面中显示 必须提供get()

    <action name="list" class="cn.itcast.action.UserAction" method="execute">
    			<param name="savepath">/strutsDemo</param>
    			<result name="success">/employee.jsp?username=${username}
                            </result>
    </action>
    

     若对某action进行访问,默认使用.action后缀访问Action。其实默认后缀是可以通过常量“struts.action.extension”进行修改  我们可以配置Struts2只处理以.do为后缀的请求路径

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">
    <struts>
    <constant name="struts.action.extension" value="do"/>
    </struts>
    

    如果用户需要指定多个请求后缀 ,则多个后缀之间以英文逗号【,】
    隔开

    <constant name="struts.action.extension" value="do,go"/>
    

     常量可以在struts.xml或struts.properties中配置,建议在struts.xml中配置,两证配置方式如下:
    <struts>
    <constant name="struts.action.extension" value="do,go,action"/>
    <struts>

    在struts.properties中配置常量
    struts.action.extension=do

  • 相关阅读:
    IntelliJ IDEA 2017版 SpringBoot的核心配置详解
    路由追踪程序traceroute/tracert分析与科普
    traceroute追踪路由命令
    ping 命令
    hostname命令,修改主机名及host文件
    net-tools工具arp命令
    ifup 和 ifdown
    net-tools工具ifconfig 命令
    iproute2 对决 net-tools
    什么是带内管理 带外管理
  • 原文地址:https://www.cnblogs.com/lomomiao/p/4161833.html
Copyright © 2011-2022 走看看