问题
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