Problems with friendly url in spring mvc

1

Including a last page in my project I got a url problem, of which I could not identify the problem.

JSF Scenario:

  • Module Condition: href="customer service"
  • Customer Details: href="client / $ {nrPasta}"
  • Module Condition: href="customer service"

Access the attendance module, which will list all the registered clients. I select one of the clients and access the details of it, which takes me to the url "app / attendant / client / 123", until this point it works normally, but if the user resolves to click on the module link again the loaded url will be "app / service / customer / service / customer ".

@RequestMapping("/atendimento")
public class Atendimento {

  @RequestMapping("/cliente")
  public String atendimentoCliente(){};

  @RequestMapping("/{nrPasta}")
  public String atendimentoDetalhes(){}

Base URL: localhost: 8084 / app /

So, Aguem has some idea of what might be happening, because I'm not identifying my error.

Attendance.jsf

<tbody>
<c:forEach items="${cliente}" var="cl">
 <tr>
  <td>${cl.nrPasta}</td>
  <td>${cl.nome}</td>
  <td class="hidden-480">
    <span class="label label-sm label-success">Novo</span>
  </td>
  <td>
   <div class="hidden-sm hidden-xs action-buttons">
    <a class="blue" href="cliente/${cl.nrPasta}">
     <i class="ace-icon fa fa-search-plus bigger-130"></i>
    </a>
   </div>
  <div class="hidden-md hidden-lg">
   <div class="inline pos-rel">
    <button class="btn btn-minier btn-yellow dropdown-toggle" data-toggle="dropdown" data-position="auto">
     <i class="ace-icon fa fa-caret-down icon-only bigger-120"></i>
    </button>
    <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
     <li>
      <a href="cliente/${cl.nrPasta}" class="tooltip-info" data-rel="tooltip" title="View">
      <span class="blue">
       <i class="ace-icon fa fa-search-plus bigger-120"></i>
      </span>
     </a>
    </li>
   </ul>
  </div>
 </div>
</td>
</tr>
</c:forEach>
</tbody><!-- tbody -->

Module link with Service:

<ul class="submenu">
  <li class="">
    <a href="atendimento/cliente">
     <i class="menu-icon fa fa-caret-right"></i>
      Atendimento
    </a>
    <b class="arrow"></b>
  </li>
 </ul>
    
asked by anonymous 16.03.2018 / 13:25

1 answer

0

It is not considered good practice to put the Web application context or the full hardcoded address on the page. If you change anything, then you will have to search the entire project.

You are using href with relative path, then atendimento/cliente will be included at the end of any path where this link appears.

To directly reference the atendimento directory, at the root of your application, use

<a href="/atendimento/cliente">

Edited

Considering that the application context is removed when you use the absolute path and you are creating a JSF page, try using the <h:link>

<h:link value="Texto" outcome="/atendimento/cliente" />

Do not forget to include namespaces in your <html> tag:

xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"

    
16.03.2018 / 16:07