Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 弹簧形式不起任何作用_Java_Spring_Jsp_Spring Mvc - Fatal编程技术网

Java 弹簧形式不起任何作用

Java 弹簧形式不起任何作用,java,spring,jsp,spring-mvc,Java,Spring,Jsp,Spring Mvc,我正在尝试更新用户设置信息。当我点击submit时,什么也没发生 这是我的设置控制器 @Secured({ "ROLE_USER", "ROLE_ADMIN" }) @RequestMapping(value = "/settings**", method = RequestMethod.GET) public ModelAndView settings() { Authentication auth = SecurityContextHolder.getContext().getAut

我正在尝试更新用户设置信息。当我点击submit时,什么也没发生

这是我的设置控制器

@Secured({ "ROLE_USER", "ROLE_ADMIN" })
@RequestMapping(value = "/settings**", method = RequestMethod.GET)
public ModelAndView settings() {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    String userName = auth.getName();
    User userInfo = userDAO.getUserInfo(userName);
    Settings settings = userDAO.getSettingsInfo(userInfo.getDetails().getMacAddress());
    List<Plugs> plugs = userInfo.getDetails().getPlugs();
    ModelAndView model = new ModelAndView();
    model.addObject("settings", settings);
    model.addObject("plugs", plugs.get(plugs.size() - 1));
    return model;
}

@Secured({ "ROLE_USER", "ROLE_ADMIN" })
@RequestMapping(value = "/settings", method = RequestMethod.POST)
public ModelAndView settings(@Valid @ModelAttribute("settings") Settings settings, BindingResult result) {
    ModelAndView model = new ModelAndView();
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    String userName = auth.getName();
    User userInfo = userDAO.getUserInfo(userName);
    if (result.hasErrors()) {
        model.setViewName("welcome");
    } else {
        model.setViewName("settings");
        userDAO.updateSettings(userInfo);
    }

    return model;
}
@Secured({“角色\用户”、“角色\管理员”})
@RequestMapping(value=“/settings**”,method=RequestMethod.GET)
公共模型和视图设置(){
Authentication auth=SecurityContextHolder.getContext().getAuthentication();
字符串userName=auth.getName();
User userInfo=userDAO.getUserInfo(用户名);
设置设置=userDAO.getSettingsInfo(userInfo.getDetails().getMacAddress());
List plugs=userInfo.getDetails().getPlugs();
ModelAndView模型=新的ModelAndView();
model.addObject(“设置”,设置);
model.addObject(“plugs”,plugs.get(plugs.size()-1));
收益模型;
}
@安全({“角色\用户”、“角色\管理员”})
@RequestMapping(value=“/settings”,method=RequestMethod.POST)
公共模型和视图设置(@Valid@modeldattribute(“设置”)设置,BindingResult){
ModelAndView模型=新的ModelAndView();
Authentication auth=SecurityContextHolder.getContext().getAuthentication();
字符串userName=auth.getName();
User userInfo=userDAO.getUserInfo(用户名);
if(result.hasErrors()){
model.setViewName(“欢迎”);
}否则{
model.setViewName(“设置”);
更新设置(userInfo);
}
收益模型;
}
JSP表单

<form:form method="POST" modelAttribute="settings" commandName="settings">

这是我的提交按钮

<input type="submit" value="submit" name ="submit">


我如何让我的表格做任何事情?它应该更新MySQL数据库中的用户详细信息。如果您想发布更多的代码,我会添加它。

您可以尝试在表单标签中添加操作属性,如下所示吗

<form:form method="POST" modelAttribute="settings" commandName="settings" action="/settings">

如果您的Springframework DispatcherServlet映射的url模式不是web.xml中的“/”,请将该模式附加到“/settings”之前,如下所示:

<form:form method="POST" modelAttribute="settings" commandName="settings" action="{url pattern}/settings">

您能否尝试在表单标签中添加操作属性,如下所示

<form:form method="POST" modelAttribute="settings" commandName="settings" action="/settings">

如果您的Springframework DispatcherServlet映射的url模式不是web.xml中的“/”,请将该模式附加到“/settings”之前,如下所示:

<form:form method="POST" modelAttribute="settings" commandName="settings" action="{url pattern}/settings">


什么是“什么都没有”的意思?模型是空的吗?提交后,您是否获得状态代码(200以外)?提交是否有效?@fateddy“什么都不做”的意思是它实际上什么都不做。“提交”按钮不起任何作用。没有状态代码或任何东西。所以按下提交按钮不会启动post请求?提交按钮是否在
中?如果您在调试模式下打开浏览器,您是否看到帖子?啊,我很愚蠢。我的提交表格中有一个注销表格,导致提交表格没有做任何事情“什么都没有”是什么意思?模型是空的吗?提交后,您是否获得状态代码(200以外)?提交是否有效?@fateddy“什么都不做”的意思是它实际上什么都不做。“提交”按钮不起任何作用。没有状态代码或任何东西。所以按下提交按钮不会启动post请求?提交按钮是否在
中?如果您在调试模式下打开浏览器,您是否看到帖子?啊,我很愚蠢。我的提交表单中有一个注销表单,导致提交表单无法执行任何操作。您可以共享您的web.xml和Spring web配置文件xml吗?您可以共享您的web.xml和Spring web配置文件xml吗?