【问题标题】:Someone help me on ajax in Spring MVC有人在 Spring MVC 中帮助我处理 ajax
【发布时间】:2015-10-23 13:33:55
【问题描述】:
I have a login.jsp contain: 2 text box username and password:

    <h1 id="loginID">Login required</h1>
    <form>
        <input type="text" name="username"><br> <br /> <input
            type="password" name="password" required> <br> <br>
        <input type="submit" onclick="loginEvent()" value="login">
    </form>

, and an javaScript file called loginAjax.js:

// 我的 loginAjax.jsp 位于 WEB-INF/resources/pages/loginAjax.jsp // 我的 spring-mvc-servlet.xml :

    xmlHttp.onreadystatechange = stateChanged;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null)
}
and a file JSP loginAjax.jsp to access database :

//在浏览器中运行时ajax不起作用!

and in console of Browser :
error: GET http://localhost:8899/SpringMVCHibernateTransaction/%3Cc:url%20value= 404 (Not Found)

【问题讨论】:

  • 那么你能指导我在春季从 Ajax 调用请求到控制器吗?例如:我认为:我将在我的 Controller 中创建 @RequestMapping("/user"),然后 ajax 将调用 $.ajax({ url:'user.jsp',// 我认为这将映射到 //@ RequestMapping("/user") data:({name:'luong'}), success:function(data){ $("#user").html(data); } });

标签: javascript ajax spring jsp


【解决方案1】:

Ajax 是用于创建异步 Web 应用程序的客户端技术。这里的错误是 404。所以,Ajax 可以正常工作。但是Server中没有对应的资源。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-14
    • 2015-04-28
    • 1970-01-01
    • 2012-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多