小编sau*_*abh的帖子

@jsonignore在春季mvc没有按预期工作

usercontroller.java

@RequestMapping("/listusersjson")
    public ResponseEntity<Iterable<User>> getListofUsersJson() {
        Iterable<User>   users = userService.listUser(); 
        return new ResponseEntity<>(users, HttpStatus.OK);

    }
Run Code Online (Sandbox Code Playgroud)

user.java

@Entity
public class User {

    @Id
    @GeneratedValue
    @Column(name="user_id")
    private Integer id;

    private String name;

    private String email;

    private String password;

    private int enabled;

    public User(Integer id) {
        super();
        this.id = id;
    }


    public User() {
        super();
    }

    @ManyToMany(cascade = CascadeType.ALL)
    @JoinTable(name = "user_role", joinColumns = { @JoinColumn(name = "user_id") }, inverseJoinColumns = {
            @JoinColumn(name = "role_id") })
    @JsonIgnore
    private List<Role> roless;

    @OneToMany(mappedBy = "user", …
Run Code Online (Sandbox Code Playgroud)

java spring json spring-mvc

2
推荐指数
1
解决办法
2142
查看次数

jquery ajax中的url生成

$(document).ready(function () {
    $(".linkDelete").click(function () {
        var userid = $(this).attr("id");
        console.debug("saurabh userid", userid);

        var url = "/delete?id=" + userid;
        var s = "SpringHibernateAnnotations";
        console.debug("saurabh url", url);
        $.ajax({
            url: s + "/delete?id=" + userid,
            success: function (data) {
                $('#result').html(data);
            }
        });
    });
});
Run Code Online (Sandbox Code Playgroud)

我有这个jquery ajax函数生成这个URL GET http:// localhost:8080/SpringHibernateAnnotations/SpringHibernateAnnotations/delete?id = 253 404(Not Found)而不是它应该生成 http:// localhost:8080/SpringHibernateAnnotations/delete? id = 253 404,如果我删除var s ="SpringHibernateAnnotations"; 并将我的url保存在ajax方法中作为url:"/ delete?id ="+ userid,它生成http:// localhost:8080/delete?id = 253,因为我无法进入application.So怎么能我生成这个正确的URL http:// localhost:8080/SpringHibernateAnnotations/delete?id = 253

ajax jquery

0
推荐指数
1
解决办法
64
查看次数

标签 统计

ajax ×1

java ×1

jquery ×1

json ×1

spring ×1

spring-mvc ×1