Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

137
Vistas
Limitation of path in Spring

I came across an interesting question while working with Spring and REST API and that problem is: Is the path limited to a certain number of characters in Spring?

The code is as follows

@RequestMapping(value = {REST_PREFIX + "/{key}"}, method = {RequestMethod.GET})
public DashboardItem getExceptionByKey(@PathVariable("key") String key, HttpServletRequest request, HttpServletResponse httpResponse_p) {
    log.info("URL is {}", request.getRequestURL());
    log.info("Key is {}", key);
    return InspectionUtils.getExceptionByKey(key);
}

An example of a key is

67E4D2C089CBCCA2A9732F6986124C6B10.243.2.107#0EEE5EAB06ED4FFF82A8934F7058860C#79A2F0C170A028A3B0410F0F16303F41

When sending the request I made sure to encode the URL and in my program the URL I am receiving is the following

/rest/exceptions/67E4D2C089CBCCA2A9732F6986124C6B10.243.2.107#0EEE5EAB06ED4FFF82A8934F7058860C#79A2F0C170A028A3B0410F0F16303F41

Thus I am receiving the hole key, but when it parses it, the variable key is only

67E4D2C089CBCCA2A9732F6986124C6B10.243.2

I thought that it may be special characters, but it doesn't look like it. My second guess is that there is a limitation for the length of the path.

So my question to you is if there is a limitation regarding the path or is there another problem?

Thank you

about 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

This is some kind of spring convention that treats everything after the last dot as a file extension and cuts it off. You could simply try adding a trailing / in your request mapping and the request. I.e. REST_PREFIX + "/{key}/"

For a more complicated but better solution if you are not the one calling your API see this question

about 4 years ago · Santiago Trujillo Denunciar

0

It must be the hash # character in your key which is not getting URL encoded. And since anything that comes after # in the URL represents different fragments of the HTML page, it never gets sent to the server.

On using javascript's encodeURIComponent() on your key i got:

67E4D2C089CBCCA2A9732F6986124C6B10.243.2.107%230EEE5EAB06ED4FFF82A8934F7058860C%2379A2F0C170A028A3B0410F0F16303F41

Notice the # character is now encoded. Try this, but you might need to decode it on your server.

about 4 years ago · Santiago Trujillo Denunciar

0

The # character has a special meaning in a URL. It is a fragment identifier, and it is used to jump to a certain part of a page (instead of landing at the top). To avoid this, encode the character as %23.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda