我是 spring 的新手,尝试创建应用程序,以便我可以了解它的工作原理。但是当我写代码时Eclipse IDE gives
无法解析类型 javax.servlet.http.HttpServletResponse。它是从所需的 .class 文件中间接引用的
这是我的课
package testPackage;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import domain.serviceLayer.UserService;
import domain.userDetails.User;
@SuppressWarnings("deprecation")
public class UserLoginFormController extends SimpleFormController {
private UserService userService;
public UserLoginFormController() {
setCommandClass(User.class);
setCommandName("user");
}
public void setUserService(UserService userService) {
this.userService = userService;
}
@Override
public ModelAndView onSubmit(Object command) throws Exception {
// TODO Auto-generated method stub
User user = (User) command;
userService.add(user);
ModelAndView modelAndView = new ModelAndView("success", "user", user);
return modelAndView;
}
}
和 pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>learnSimpleFormController</groupId>
<artifactId>learnSimpleFormController</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<properties>
<spring.version>3.2.3.RELEASE</spring.version>
</properties>
<dependencies>
<!-- Spring 3 dependencies -->
<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>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<finalName>learnSimpleFormController</finalName>
</build>
</project>
请问是什么问题以及如何消除该错误