How to accurately determine whether a request is a `Ajax` request or a traditional `URL` request in Java?

the test uses the handler method to determine that it does not work. Front and back code:

request.getHeader("X-Requested-With")

whether it is url access or fetch asynchronous access, you will only get null !

Apr.09,2021

this requires the cooperation of the front desk.
you just add X-Requested-With http headers when you fetch.
jQuery's ajax requests are all


fetch('http://localhost:8181/1',{
headers:{
    'X-Requested-With':'XMLHttpRequest'
}
})
with this header added.
Menu