<bdo id='qnWLe'></bdo><ul id='qnWLe'></ul>

    <tfoot id='qnWLe'></tfoot>
    1. <small id='qnWLe'></small><noframes id='qnWLe'>

      <i id='qnWLe'><tr id='qnWLe'><dt id='qnWLe'><q id='qnWLe'><span id='qnWLe'><b id='qnWLe'><form id='qnWLe'><ins id='qnWLe'></ins><ul id='qnWLe'></ul><sub id='qnWLe'></sub></form><legend id='qnWLe'></legend><bdo id='qnWLe'><pre id='qnWLe'><center id='qnWLe'></center></pre></bdo></b><th id='qnWLe'></th></span></q></dt></tr></i><div id='qnWLe'><tfoot id='qnWLe'></tfoot><dl id='qnWLe'><fieldset id='qnWLe'></fieldset></dl></div>
    2. <legend id='qnWLe'><style id='qnWLe'><dir id='qnWLe'><q id='qnWLe'></q></dir></style></legend>

      1. Spring:在属性文件中定义 @RequestMapping 值

        时间:2023-07-26
        • <legend id='ahOUC'><style id='ahOUC'><dir id='ahOUC'><q id='ahOUC'></q></dir></style></legend>
            <bdo id='ahOUC'></bdo><ul id='ahOUC'></ul>
            <i id='ahOUC'><tr id='ahOUC'><dt id='ahOUC'><q id='ahOUC'><span id='ahOUC'><b id='ahOUC'><form id='ahOUC'><ins id='ahOUC'></ins><ul id='ahOUC'></ul><sub id='ahOUC'></sub></form><legend id='ahOUC'></legend><bdo id='ahOUC'><pre id='ahOUC'><center id='ahOUC'></center></pre></bdo></b><th id='ahOUC'></th></span></q></dt></tr></i><div id='ahOUC'><tfoot id='ahOUC'></tfoot><dl id='ahOUC'><fieldset id='ahOUC'></fieldset></dl></div>

                <tbody id='ahOUC'></tbody>

              1. <small id='ahOUC'></small><noframes id='ahOUC'>

              2. <tfoot id='ahOUC'></tfoot>

                • 本文介绍了Spring:在属性文件中定义 @RequestMapping 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  是否可以通过在属性文件中定义 @RequestMapping 注释在 Spring 中定义它的值?

                  Is it possible to define the value of a @RequestMapping annotation in Spring by defining it in a properties file?

                  实际上,我会这样做:

                  @Controller
                  @RequestMapping("/xxx")
                  public class MyController {
                  ...
                  }
                  

                  但我想将路径 /xxx 存储在属性文件中.为什么?例如,如果我在控制器中重命名路径,我就不太可能在模板中做 mystakes.

                  But I would like to store the path /xxx in a properties file. Why? For instance, it is less likely that I do mystakes in my templates if I rename the path in the controller.

                  在其他框架中这是允许的(例如,参见 Symfony).

                  In other framework this is allowed (see Symfony, for instance).

                  推荐答案

                  应该可以在 @RequestMapping 中使用占位符,例如 @RequestMapping("${foo.bar}").看看 文档了解更多详情:

                  It should be possible to use placeholders in @RequestMapping, like for example @RequestMapping("${foo.bar}"). Take a look at the documentation for more details:

                  @RequestMapping 注释中的模式支持针对本地属性和/或系统属性和环境变量的 ${... } 占位符.这在控制器映射到的路径可能需要通过配置进行自定义的情况下可能很有用.有关占位符的更多信息,请参阅 PropertyPlaceholderConfigurer 类的 javadocs.

                  Patterns in @RequestMapping annotations support ${…​} placeholders against local properties and/or system properties and environment variables. This may be useful in cases where the path a controller is mapped to may need to be customized through configuration. For more information on placeholders, see the javadocs of the PropertyPlaceholderConfigurer class.

                  这篇关于Spring:在属性文件中定义 @RequestMapping 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何编写 Java 注释处理器? 下一篇:一个元素上有多个相同类型的注释?

                  相关文章

                  最新文章

                • <i id='cPnjY'><tr id='cPnjY'><dt id='cPnjY'><q id='cPnjY'><span id='cPnjY'><b id='cPnjY'><form id='cPnjY'><ins id='cPnjY'></ins><ul id='cPnjY'></ul><sub id='cPnjY'></sub></form><legend id='cPnjY'></legend><bdo id='cPnjY'><pre id='cPnjY'><center id='cPnjY'></center></pre></bdo></b><th id='cPnjY'></th></span></q></dt></tr></i><div id='cPnjY'><tfoot id='cPnjY'></tfoot><dl id='cPnjY'><fieldset id='cPnjY'></fieldset></dl></div>

                  1. <tfoot id='cPnjY'></tfoot>

                      • <bdo id='cPnjY'></bdo><ul id='cPnjY'></ul>

                      <small id='cPnjY'></small><noframes id='cPnjY'>

                      <legend id='cPnjY'><style id='cPnjY'><dir id='cPnjY'><q id='cPnjY'></q></dir></style></legend>