Bval ValidationMessages.properties in scala eclipse project

笑着哭i 提交于 2019-12-12 00:55:34

问题


I have a scala project (based around unfiltered and jetty) which uses bval. I've tried everything I can think of to get custom validation messages to load from a properties file, but it just doesn't work. I have a scala class like this:

class AddName{
    @NotEmpty(message = "{firstName.notEmpty}")
    var firstName: String = ""
    @NotEmpty(message = "{lastName.notEmpty}")
    var lastName: String = ""
}

and a ValidationMessages.properties file containing the following:

firstName.notEmpty=enter a first name
lastName.notEmpty=enter a last name

But the output from the validation results is {firstName.notEmpty} not matter what I try.

I have tried placing the properties file in the project root, in a resource folder which is exported to the classpath by the run configurations. I've also tried placing it in the target/scala-2.9.1/classes folder and then running the project with sbt compile.

来源:https://stackoverflow.com/questions/15748884/bval-validationmessages-properties-in-scala-eclipse-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!