angular.js:GET 无法加载资源:服务器响应状态为404(未找到)
以下是代码:
1)Maincontroller.js
$scope.autologin=function(){
var username = 'admin';
var password = 'admin';
//put here the ajax get to logincheck
$http.get("/uatload/logincheck?username="+username+"&password="+password)
.success(function(response) {
$rootScope.logged = true
$location.path('/form');
})
.error(function(){
$location.path('/error');
});
};
$scope.autologin();
});
2)Logincheck.java(servlet)
@WebServlet(name = "LoginCheck", urlPatterns = { "/logincheck" })
public class LoginCheck extends HttpServlet {
private static final long serialVersionUID = 1L;
// springboot startup class。
@Configuration
@ComponentScan(basePackages="com.validatelogin")
@EnableAutoConfiguration
public class UATLoaderApp extends SpringBootServletInitializer {
}
但是,当我浏览jsp并将url更改为(“/uatload/logincheck.jsp?username =”+ username +“& password =”+ password)时,Get请求正常工作
logincheck.js
<jsp:useBean id="db" class="com.validatelogin.LoginCheck" />
<%
System.out.println("logincheck CALL");
db.doGet(request, response);
%>
我使用带有嵌入式tomcat 8的spring boot 1.3.1。
提前致谢。
答案 0 :(得分:0)
Spring Boot默认不扫描@WebServlet
或@WebFilter
。您需要use @ServletComponentScan
to enable it:
@Configuration
@ComponentScan(basePackages="com.validatelogin")
@ServletComponentScan(basePackages="com.validatelogin")
@EnableAutoConfiguration
public class UATLoaderApp extends SpringBootServletInitializer {
}