1

I use spring mvc and after a ajax call get sometimes a 400 error

    $.ajax({
        url : 'save_ao', type : 'post', 
        data : $('#formDepot').serialize() ,
        success : function(CODE) {   
            ...
        },      
        error : function(){ alert("error"); }
    }); 

My form bean has many fields i can't put them all here

@RequestMapping(value="/save_ao") 
public @ResponseBody
String save_ao(@ModelAttribute(value="infoao") DepotAObean infoao,
            ModelMap model) {

           ...
           ...
}

what is going to drive me crazy is that sometimes the ajax call works and sometimes it give me 400 error knowing that i put the same data in my jsp form <form:form id="formDepot" method="get" modelAttribute="infoao" > !!!

Also in server side (Apache tomcat) doesn't show me no error or exception so how can 400 errors be logged ?

Here's my log4j2 config :

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
    <Appenders>
        <Console name="CONSOLE" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
        </Console>
    </Appenders>
    <Loggers>

        <Root level="DEBUG">
            <AppenderRef ref="CONSOLE"/>
        </Root>

        <logger name="org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver" level="DEBUG" />


    </Loggers>
</Configuration>
Hayi
  • 6,972
  • 26
  • 80
  • 139

2 Answers2

1
  1. Look at DefaultHandlerExceptionResolver, which handles errors in Spring Web MVC. I would debug through DefaultHandlerExceptionResolver first.
  2. DefaultHandlerExceptionResolver logs exceptions with WARN level, so look for warnings like: Handling of [" + ex.getClass().getName() + "] resulted in Exception
mavarazy
  • 7,562
  • 1
  • 34
  • 60
  • i update the question with my log4j2 config but i don't get no logging !! – Hayi Jul 09 '14 at 14:16
  • this question is solved so i have created a new one. http://stackoverflow.com/questions/24658384 – Hayi Jul 09 '14 at 16:11
0

The problem is solved Because it occurs when i put non compatible data in my form.
I have a field in my form bean infoao which expect a Double but i enter a String value with character not only numbers.

Hayi
  • 6,972
  • 26
  • 80
  • 139