Spring mvc 发送http请求don';我不能正常工作
我有一个ExtJS4表单,我正在发送信息以将其保存在数据库中。我正在使用SpringSecurity和SpringMVC 因此,在提交函数中的extjs表单中,我使用这个urlSpring mvc 发送http请求don';我不能正常工作,spring-mvc,extjs4,Spring Mvc,Extjs4,我有一个ExtJS4表单,我正在发送信息以将其保存在数据库中。我正在使用SpringSecurity和SpringMVC 因此,在提交函数中的extjs表单中,我使用这个url method:'POST', url: 'meeting/create.action', 在我的控制器上我用这个 @RequestMapping(value = "/meeting/create.action", method = RequestMethod.POST) public void add
method:'POST',
url: 'meeting/create.action',
在我的控制器上我用这个
@RequestMapping(value = "/meeting/create.action", method = RequestMethod.POST)
public void add(MeetingUI data) {
System.out.println("In add post method");
MeetingUI savedUser = service1.create(data);
if (savedUser != null) {
logger.debug(" Created Succesfully");
} else {
logger.debug("Error trying to create account.");
}
}
未收到任何数据。数据库中保存的信息为空
以及显示的其他错误
HTTP Status 404 - /writeup/WEB-INF/meeting/create.jsp
我不希望/meeting/create.action与spring security集成,我想这就是错误所在
请任何人都有一个解决方案您的处理程序方法的返回类型为
void
。阅读第13.11.4节。中支持的处理程序方法参数和返回类型,您可以看到
如果方法本身处理响应(通过写入
直接响应内容,声明类型为的参数
ServletResponse/HttpServletResponse)或
名称应该通过
RequestToViewNameTranslator(未在
处理程序方法签名)
RequestToViewNameTranslator
的唯一Spring实现是DefaultRequestToViewNameTranslator
,它说
RequestToViewNameTranslator,它只转换
传入到视图名称中的请求
及
下面是一些请求查看名称翻译的示例
http://localhost:8080/gamecast/display.html
->显示
这会将您的/meeting/create.action
的URI映射到会议/创建
。然后我假设您有一些用于jsp
文件的视图解析器。这可能以/WEB-INF/
作为路径的前缀,并以.jsp
作为其后缀,最终成为/WEB-INF/meeting/create.jsp
,而您可能没有该路径,因此404
使您的方法返回视图名称的字符串,或使其写入响应主体本身
您的方法可能如下所示:
@RequestMapping(value = "/meeting/create.action", method = RequestMethod.POST)
public Stringadd(MeetingUI data) {
System.out.println("In add post method");
MeetingUI savedUser = service1.create(data);
if (savedUser != null) {
logger.debug(" Created Succesfully");
return "success";
} else {
logger.debug("Error trying to create account.");
return "error";
}
}
你能给我一个电话吗example@Amin刚刚将您的方法更改为上面的方法,其中
success
映射到名为success.jsp
的jsp,对于error
也是如此。我只使用extjs,我有一个jsp页面用于加载extjsscripts@Aminextjs如何决定运行哪个脚本?