角度发送失败

时间:2015-07-04 14:22:27

标签: java angularjs spring post jersey

发送邮件到服务器时遇到问题。我正在使用运动衫。 在棱角分明,我做到了这样:

services.factory('UserService', function($resource) {

return $resource('rest/user/:action', {},
        {
            authenticate: {
                method: 'POST',
                params: {'action' : 'authenticate'},
                headers : {'Content-Type': 'application/x-www-form-urlencoded'}
            },
        }
    );
});

$scope.login = function() {
        UserService.authenticate($.param({username: $scope.username, password: $scope.password}), function(authenticationResult) {
            var authToken = authenticationResult.token;
            $rootScope.authToken = authToken;
            if ($scope.rememberMe) {
                $cookieStore.put('authToken', authToken);
            }
            UserService.get(function(user) {
                $rootScope.user = user;
                $location.path("/");
            });
        });
    };

在服务器端,我有:

@Path("authenticate")
@POST
@Produces(MediaType.APPLICATION_JSON)
public TokenTransfer authenticate(@FormParam("username") String username, @FormParam("password") String password)
{
    //authentication
}

当我点击发送按钮时,我在休息时获得POST /用户/身份验证失败,状态为403。 它运作良好,因为我已经将球衣改为jersey-spring3,让它与春季4相容。

哪里有问题?

泽西岛依赖:

<dependency>
        <groupId>org.glassfish.jersey.ext</groupId>
        <artifactId>jersey-spring3</artifactId>
        <version>2.18</version>

        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aop</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
                <groupId>org.glassfish.jersey.media</groupId>
                <artifactId>jersey-media-json-jackson</artifactId>
                <version>2.18</version>
            </dependency>

              <dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.5.4</version>
</dependency>

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.5.4</version>
</dependency>

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-annotations</artifactId>
    <version>2.5.4</version>
</dependency>

0 个答案:

没有答案