我收到了这个错误,正如我在标题中提到的那样。我正在制作一个示例应用程序,它在angularJs,spring和hibernate上。我的应用程序正在使用spring,hibernate和jsp页面,但是当我无法使用angularJs时。这是html页面
<div ng-controller="empController">
<form>
<label>FirstName</label>
<input type="text" name="Firstname" ng-model="emp.firstName"/>
<br/>
<label>LastName</label>
<input type="text" name="lastName" ng-model="emp.lastName"/>
<br/>
<label>Email</label>
<input type="text" name="email" ng-model="emp.email"/>
<br/>
<label>Phone</label>
<input type="text" name="phone" ng-model="emp.phone"/>
<br/>
<input type="hidden" ng-model="emp.id" />
<input type="button" value="Save" ng-click="saveEmp()" />
</form>
下面是angularJs控制器的代码
function empController($scope,$http,$location) {
$scope.saveEmp = function(emp) {
$http.post('add', $scope.emp).success(function() {
//location.href = "index.html";
});
$scope.emp = {};
};
}
以下是springController的代码
@RequestMapping(value = "/", method = RequestMethod.GET)
public String listEmployees(ModelMap map)
{
map.addAttribute("emp", new TestEmployee());
System.out.println("calling listEmployees");
return "editEmployeeNew";
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String addEmployee(@ModelAttribute(value="emp") TestEmployee emp, BindingResult result)
{
employeeManager.addEmployee(emp);
return null;
}
下面是我的web.xml文件
<servlet>
<servlet-name>employee</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>employee</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/employee-servlet.xml</param-value>
</context-param>
以下是我的employee-servlet.xml(代码段)
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/view/" />
<property name="suffix" value=".html" />
</bean>
我在网上搜索过这个问题但没有任何帮助,因为我正在使用angularJs。请帮助我。我是这些技术的新手,如果我以错误的方式做某事,请帮助我使用代码。