大佬教程收集整理的这篇文章主要介绍了SpringMVC HTTP状态405-请求方法'POST'不支持,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
function submitPage(){
document.getElementByID("citiZenRegistration").action="getCitiZen/citiZen_registration.htm";
document.getElementByID("citiZenRegistration").target="_self";
document.getElementByID("citiZenRegistration").method = "POST";
document.getElementByID("citiZenRegistration").submit();
}
您可以按上述方式调用该方法。使用onclick绑定提交按钮的功能
我有一个表单,我从该表单中查询数据库,并将结果发布到另一页。然后,我从查询结果中选择一条记录,然后将我带回到进行查询的页面,以便我可以更新记录。
我单击“更新”,这将带我回到控制器,并再次使用相同的方法进行查询,但是现在请求的参数为“更新”,因此假设要转到该方法中的更新条件。似乎我无法将页面重新提交到相同的URL映射。
控制者
@requestMapping(value="citizen_registration.htm",method = requestMethod.POST)
public ModelAndView handlerequest(@Valid @modelAttribute Citizens citizen,BindingResult result,ModelMap m,Model model,@requestParam(value="user_request") String user_request) throws Exception {
try{
logger.debug("In http method for CitizenRegistrationController - Punishment Registration");
logger.debug("User request Is " + user_request);
if(result.hasErrors()){
//handle errors
// return new ModelAndView("citizen_registration");
}else{
//check if its a save or an update
if(user_request.equals("Save"))
//do save
else if (user_request.equals("Query"))
//do query
else if (user_request.equals("update"))
//do update
}
}
错误记录
34789 [http-bio-8084-exec-3] DEBUG org.springframework.web.servlet.DispatcherServlet - Bound request context to thread: org.apache.catalina.connector.requestFacade@2ba3ece5
34791 [http-bio-8084-exec-3] DEBUG org.springframework.web.servlet.DispatcherServlet - DispatcherServlet with name 'crimetrack' processing POST request for [/crimeTrack/getCitizen/citizen_registration.htm]
34792 [http-bio-8084-exec-3] DEBUG org.springframework.web.servlet.DispatcherServlet - TesTing handler map [org.springframework.web.servlet.mvc.method.Annotation.requestMappingHandlerMapping@3a089b3] in DispatcherServlet with name 'crimetrack'
34792 [http-bio-8084-exec-3] DEBUG org.springframework.web.servlet.mvc.method.Annotation.requestMappingHandlerMapping - Looking up handler method for path /getCitizen/citizen_registration.htm
34796 [http-bio-8084-exec-3] DEBUG org.springframework.web.servlet.mvc.method.Annotation.ExceptionHandlerExceptionResolver - Resolving exception from handler [null]: org.springframework.web.httprequestMethodNotSupportedException: request method 'POST' not supported
34796 [http-bio-8084-exec-3] DEBUG org.springframework.web.servlet.mvc.Annotation.ResponseStatusExceptionResolver - Resolving exception from handler [null]: org.springframework.web.httprequestMethodNotSupportedException: request method 'POST' not supported
34796 [http-bio-8084-exec-3] DEBUG org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver - Resolving exception from handler [null]: org.springframework.web.httprequestMethodNotSupportedException: request method 'POST' not supported
34796 [http-bio-8084-exec-3] WARN org.springframework.web.servlet.PageNotFound - request method 'POST' not supported
34796 [http-bio-8084-exec-3] DEBUG org.springframework.web.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'crimetrack': assuming HandlerAdapter completed request handling
34796 [http-bio-8084-exec-3] DEBUG org.springframework.web.servlet.DispatcherServlet - Cleared thread-bound request context: org.apache.catalina.connector.requestFacade@2ba3ece5
34796 [http-bio-8084-exec-3] DEBUG org.springframework.web.servlet.DispatcherServlet - successfully completed request
34796 [http-bio-8084-exec-3] DEBUG org.springframework.web.context.support.XmlWebApplicationContext - Publishing event in WebApplicationContext for namespace 'crimetrack-servlet': ServletrequestHandledEvent: url=[/crimeTrack/getCitizen/citizen_registration.htm]; client=[127.0.0.1]; method=[POST]; servlet=[crimetrack]; session=[null]; user=[null]; time=[8ms]; status=[OK]
34796 [http-bio-8084-exec-3] DEBUG org.springframework.web.context.support.XmlWebApplicationContext - Publishing event in Root WebApplicationContext: ServletrequestHandledEvent: url=[/crimeTrack/getCitizen/citizen_registration.htm]; client=[127.0.0.1]; method=[POST]; servlet=[crimetrack]; session=[null]; user=[null]; time=[8ms]; status=[OK]
火虫
检查FireBug,我知道"NetworkError: 405 Method Not Allowed -
http://localhost:8084/crimeTrack/getCitizen/citizen_registration.htm"
这应该是http://localhost:8084/crimeTrack
/citizen_registration.htm“
getCitizen是我第一次执行查询时转到的页面,它包含在url中。
我将jsp表单操作定义更改为,<form:form id="citizenRegistration" name
="citizenRegistration" method="POST" commandName="citizens"
action="<%=request.getContextPath()%>/citizen_registration.htm">
但是当我启动应用程序并向此页面发出请求时,我得到:
http Status 500 - /WEB-INF/jsp/citizen_registration.jsp (line: 31,column: 116) attribute for %>" is not properly terminated
以上是大佬教程为你收集整理的SpringMVC HTTP状态405-请求方法'POST'不支持全部内容,希望文章能够帮你解决SpringMVC HTTP状态405-请求方法'POST'不支持所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。