找不到符号类ModelAttribute

时间:2014-03-14 11:22:47

标签: maven spring-mvc spring-validator

我在控制器中有这样的方法

@ModelAttribute("registerForm")
public RegisterForm getRegisterForm() {
    return new RegisterForm();
}

@RequestMapping("/registration.html")
@ResponseBody
public String registration(
        @ModelAttribute("registerForm") @Valid RegisterForm form,
        BindingResult result) {

    validator.validate(form, result);

    if (result.hasErrors()) {
        logger.debug("ERRORS WAS FOUND");
    } else {
        logger.debug("NO ERRORS!");
    }

    return null;
}

但当我mvn package时,我遇到了编译错误 - cannot find symbol

在pom.xml中,我有春天的家属

<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aspects</artifactId>
        <version>${spring.version}</version>
    </dependency>

javax.validation

<dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
    </dependency>

问题是什么?

0 个答案:

没有答案