Java 在spring mvc中删除用户时出错

Java 在spring mvc中删除用户时出错,java,spring,spring-mvc,Java,Spring,Spring Mvc,我无法删除用户。这是我单击“删除”按钮时出现的错误。org.springframework.dao.TransientDataAccessResourceException:PreparedStatementCallback;SQL[从id为'1'的用户中删除];参数索引超出范围(1>参数数量,为0)。;嵌套异常为java.sql.SQLException:参数索引超出范围(1>参数数,为0)。请帮忙,谢谢 Jdbc的delete函数 public int deleteUser(int id){

我无法删除用户。这是我单击“删除”按钮时出现的错误。org.springframework.dao.TransientDataAccessResourceException:PreparedStatementCallback;SQL[从id为'1'的用户中删除];参数索引超出范围(1>参数数量,为0)。;嵌套异常为java.sql.SQLException:参数索引超出范围(1>参数数,为0)。请帮忙,谢谢

Jdbc的delete函数

public int deleteUser(int id){
        String SQL = "DELETE FROM users WHERE id = '"+id+"'";
        System.out.print(SQL);
        int user = jdbcTemplateObject.update(SQL, id);
        return user;
    }
删除控制器

RequestMapping(value = "/delete", method = RequestMethod.GET)
    public ModelAndView delete(@ModelAttribute("SpringWeb")User user, ModelMap model, HttpServletRequest request)
    {
        try
        {
            SyntacksJdbc syntacksJdbc = (SyntacksJdbc)context.getBean("syntacksJdbc");
            System.out.println(request.getParameter("id"));
            int id = Integer.parseInt(request.getParameter("id"));
            int user1 = syntacksJdbc.deleteUser(id);
            model.addAttribute("message", "Questions updated successfully.");
        }
        catch(Exception e)
        {
            System.out.print(e);
            model.addAttribute("message", "Error occured in posting question.");
        }

        return new ModelAndView("users");
在我的jsp按钮上

 <a href="/Project/delete?id=${user.id}" name="delete"><button type= submit>Delete</button>
删除
将查询更改为

DELETE FROM users WHERE id = ?

由于您正在尝试设置参数值

将查询更改为
从id=?
的用户中删除,感谢它的工作。它现在会删除记录,但在将其返回页面时,我遇到了另一个问题。结果是找不到一个页面,但用户被删除了,但删除后您在URL中看到了什么?您的视图解析器是如何配置的?url上的是delete/id?=1。它返回未找到的页面。它不会返回到users.jspHi Jigar Joshi页面,从spring security可以使用什么作为参数?