小编new*_*all的帖子

在罐子中包含属性/配置文件是不好的做法吗?

例如:

MyApp是一个Web应用程序,其中包含一个属性文件(server.properties),用于描述应用程序的配置数据(例如服务器名称).在开发阶段,server.properties位于其自己的IDE项目文件夹(它的逻辑位置)中.

现在是时候部署MyApp了.IDE使得类文件以及支持配置文件变得非常简单.现在我们只是将Jar放入适当的Web容器中然后我们就去....

一周后...... MyApp使用的服务器配置数据需要更改.哪个更有意义?

A.在IDE域中修改server.properties文件并生成一个全新的jar文件.重新部署.(这意味着弹出应用程序以进行简单的配置更改).

B.破解已部署的Jar并修改server.properties文件?(如果缓存了server.properties,可能必须在MyApp中调用刷新函数...但不应该要求完整的应用程序反弹.还需要记住修改源server.properties以便将来的部署不会还原server.properties到旧的服务器名称).

C.首先将server.properties置于jar文件的外部.与B的过程非常相似,将配置数据保存在jar外部的细微差别(在开发和生产部署之间引入了不同的路径)

D.其他:

谢谢!

java configuration jar properties

21
推荐指数
4
解决办法
9202
查看次数

如何正确标记/样式有序列表以补偿大项目编号

我正在动态生成包含有序列表的网页.该页面包含10个项目,并使用属性"start"相应地对项目进行编号.具有'list-style-position:outside'的通用有序列表对于项目编号小于1000的项目非常适用.

当项目编号的长度为4位或更多时,问题就出现了,项目编号的一部分被容器边界部分遮挡.调整列表填充并不是一个真正的解决方案,因为对于具有比填充调整后要处理的更多位数的项目计数,它仍将中断,以及由于过度填充而使单个数字项看起来很糟糕.

使用'list-style-position:inside'解决了项目编号被遮挡的问题,但引入了一个新问题,因为这样做会导致项目内容包装在列表项目编号下,而不是对齐到数字的右侧.

我总是可以隐藏项目编号并在每个<li>中引入一个新的浮动div并将内容设置为列表项目编号,但是虽然这解决了我的演示文稿问题,但语义上它不太正确,因为我正在添加标记和内容纯粹出于表现的原因.

对于我不知道的这种困境,有没有css解决方案?

    <style>
        #container {
            border: solid;
        }

        #container div, #container h1 {
            border: solid 1px blue;
        }

        #outsideOl {
            list-style-position: outside;
        }

        #insideOl {
            list-style-position: inside;
            padding-left: 0;
        }

    </style>



    <div id="container">

    <ol id="outsideOl" start="3000">
        <li><h1>one</h1><div>the content inside the &lt;li&gt; is aligned to the right of the numbers, which is what I want, but long numbers are obscured by the container's border.  The list elements are shifted to the right by the default padding for an …
Run Code Online (Sandbox Code Playgroud)

html css semantic-markup

5
推荐指数
1
解决办法
557
查看次数

XSLT:执行流程的调用模板与模式

哪个是用于执行流、调用模板或模式的更好实践?

数据文件

<Properties>
    <foo>me</foo>
    <bar>you</bar>
</Properties>
Run Code Online (Sandbox Code Playgroud)

一个.xsl

<xsl:include href="translations_nomodes.xml"
<xsl:template match="/">
    <xsl:call-template name="a_display"/>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)

b.xsl

<xsl:include href="translations_nomodes.xml"
<xsl:template match="/">
    <xsl:call-template name="b_display"/>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)

翻译_nomodes.xsl

<xsl:template name="a_display">
    <!-- display option a -->
    ...
</xsl:template>

<xsl:template name="b_display">
    <!-- display option b -->
    ...
</xsl:template>
Run Code Online (Sandbox Code Playgroud)

或者使用模式是更好的做法

.xsl

<xsl:include href="translations_modes.xml"
<xsl:template match="/">
    <xsl:apply-templates select="/Properties" mode="c_display"/>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)

d.xsl

<xsl:include href="translations_modes.xml"
<xsl:template match="/">
    <xsl:apply-templates select="/Properties" mode="d_display"/>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)

翻译模式.xsl

<xsl:template match="Properties" mode="c_display">
    <!-- display option c -->
    ...
</xsl:template>

<xsl:template match="Properties" mode="d_display">
    <!-- display option d -->
    ... …
Run Code Online (Sandbox Code Playgroud)

xml xslt

5
推荐指数
1
解决办法
6978
查看次数

spring 3.0 MVC似乎忽略了messages.properties

Spring 3.0 MVC

首先,我没有找到任何关于messages.properties @ springsource的文档. 我发现有关覆盖错误消息的所有内容都在各种论坛上.如果有人提到了messages.properties的记录,那就太棒了.也许messages.properties不是来自spring而是java规范?

我已经尝试遵循关于绑定之前的JSR-303类型检查的建议 我的目标是用我自己的用户友好错误消息替换一些类型不匹配错误消息

我的情况如下:

模型

public class Test {

    private int numberbomb;

    public int getNumberbomb() {
        return numberbomb;
    }

    public void setNumberbomb(int numberbomb) {
        this.numberbomb = numberbomb;
    }
}
Run Code Online (Sandbox Code Playgroud)

myservlet.xml

<mvc:annotation-driven/>
Run Code Online (Sandbox Code Playgroud)

JSP

<form:form id="test" method="post" modelAttribute="test">

<form:errors path="*"/>

<form:label path="numberbomb">numberbomb</form:label>
<form:input path="numberbomb"/>

</form:form>
Run Code Online (Sandbox Code Playgroud)

类\ messages.properties

typeMismatch=bad value you bad bad person
test.numberbomb=you are driving me crazy with these bad inputs
Run Code Online (Sandbox Code Playgroud)

表格输出

无法将类型为java.lang.String的属性值转换为属性numberbomb所需的int类型; 嵌套异常是org.springframework.core.convert.ConversionFailedException:无法将类型java.lang.String中的值"three"转换为int类型; 嵌套异常是java.lang.NumberFormatException:对于输入字符串:"three"

我的控制器中的BindingResult.toString()

字段'numberbomb'上对象'test'中的字段错误:被拒绝的值[3]; 码[typeMismatch.test.numberbomb,typeMismatch.numberbomb,typeMismatch.int,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable:codes [test.numberbomb,numberbomb]; 参数[]; …

forms model-view-controller spring-3

5
推荐指数
1
解决办法
5941
查看次数