zoukankan      html  css  js  c++  java
  • Struts2的struts.properties文件在哪儿啊?

    老师教我们Struts2的时候叫我们建了个Struts.xml文件啊?那struts.properties呢?不需要吗?

    回答1:
    struts.properties 是可以不要的!!!
    因为 struts.xml文件中 有 <constant> 这个节点, 你可以把你想写在struts.properties的自定义配置写在 struts.xml文件当中.

    例如,你想 开启 struts2 的开发模式
    可以直接在 struts.xml文件当中写上.
    <constant name="struts.devMode" value="true“>
    不用再去 去创建 一个 struts.properties,并写上 struts.devMode = true

    所有的配置项目,其实 你可以去看看 struts2 默认的配置文件 default.properties.
    位置在 struts2-core-2.x.x.jar 的 org.apache.struts2 包 下面的

    当然,你可能又会问了,如果同时都在两个文件配置了,一个相同的项目,哪个是有效的呢
    他其实是有一个加载顺序的: 先加载 struts.xml,再加载 struts.properties
    也就是说 struts.properties 是可以覆盖 struts.xml里面的 配置的,
    具体 是否 要 struts.properties ,还是得根据 具体情况,具体分析吧,
    不过 我基本上不用,免得 出现 配置混乱的情况.呵呵

    PS: struts.xml 不能写成Struts.xml 哟 ,注意首字母 s不能写成大写了.

    回答2:
    需要,这个文件可以做一些相同的配置。
    比如properties中:
    #可以修改访问路径的后缀为do,action两个都可以 
    struts.action.extension=do,action
    也可以在xml文件中同样设置:
    <constant name="struts.action.extension" value="do,action“>
  • 相关阅读:
    React Native 使用 react-native-webview 渲染 HTML
    如何对 React 函数式组件进行优化?
    如何在前端中使用protobuf?
    Grunt之预处理
    基于Hooks 的 Redux 速成课
    AssemblyScript 入门指南
    webpack常用构建优化总览
    如何在前端中使用protobuf(node篇)
    哪种编程语言最适合区块链?
    hdu 相遇周期
  • 原文地址:https://www.cnblogs.com/xuan52rock/p/4745918.html
Copyright © 2011-2022 走看看