Html 在SpringBoot应用程序中映射我的JSP时出现问题
首先,我在所有jsp页面上都设置了页眉和页脚。 登录页映射为“/”。 页脚中的第一个链接映射为“/Recruement”。 页脚中的第二个链接映射为“/service”。 在recruement.jsp(第一个页脚链接)中,我有一个链接映射到“/annonce”。 当我在annonce.jsp上时,url是。在这里之前一切都很好。 但是,在annonce.jsp上,如果我单击第二个页脚链接,url将以类似而不是仅仅 我想我的映射可能有错误?或者使用viewResolver? 谢谢你的帮助 所有3名相关控制员:Html 在SpringBoot应用程序中映射我的JSP时出现问题,html,spring,spring-boot,jsp,Html,Spring,Spring Boot,Jsp,首先,我在所有jsp页面上都设置了页眉和页脚。 登录页映射为“/”。 页脚中的第一个链接映射为“/Recruement”。 页脚中的第二个链接映射为“/service”。 在recruement.jsp(第一个页脚链接)中,我有一个链接映射到“/annonce”。 当我在annonce.jsp上时,url是。在这里之前一切都很好。 但是,在annonce.jsp上,如果我单击第二个页脚链接,url将以类似而不是仅仅 我想我的映射可能有错误?或者使用viewResolver? 谢谢你的帮助 所有3
@Controller
@RequestMapping(path = "/")
public class AccueilController {
@GetMapping(path = "/")
public String showAccueil(Model theModel, HttpSession session) {
...
return "index";
}
}
@Controller
@RequestMapping("/recrutement")
public class RecrutementController {
@Autowired
private JobOfferRepository jor;
@GetMapping(path = "")
public String showRecrutement(Model theModel) {
List<JobOffer> ajo = jor.findAll();
theModel.addAttribute("jobOfferList", ajo);
return "recrutement";
}
@GetMapping(path = "/{id}")
public String showJobOffer(Model theModel, @PathVariable int id){
JobOffer jo = jor.findById(id).get();
theModel.addAttribute("jobOffer", jo);
return "recrutementAnnonce";
}
}
@Controller
@RequestMapping("/")
public class StaticPagesController {
@GetMapping(path = "/services")
public String showServices() {
return "services";
}
}
@控制器
@请求映射(路径=“/”)
公共类精确控制器{
@GetMapping(路径=“/”)
公共字符串showAccueil(模型,HttpSession会话){
...
返回“索引”;
}
}
@控制器
@请求映射(“/Recruement”)
公共类重现控制器{
@自动连线
私人职业介绍所;
@GetMapping(路径=“”)
公共字符串显示重现(模型模型){
List ajo=jor.findAll();
add属性(“jobOfferList”,ajo);
返回“重新创建”;
}
@GetMapping(path=“/{id}”)
公共字符串showJobOffer(模型,@PathVariable int-id){
JobOffer jo=jor.findById(id.get();
model.addAttribute(“jobOffer”,jo);
返回“一次重现”;
}
}
@控制器
@请求映射(“/”)
公共类StaticPagesController{
@GetMapping(路径=“/services”)
公共字符串showServices(){
返回“服务”;
}
}
我的页脚html:
</div> <--- opening div located at end of header
<div class="middle" >
<div class="block">
<span class="title">Services Orvif</span>
<ul>
<li><a href="services">Services</a></li>
</ul>
</div>
<div class="block">
<span class="title">Nous contacter</span>
<ul>
<li><a href="recrutement">Recrutement</a></li>
</ul>
</div>
</body>
</html>
类StaticPagesController删除@RequestMapping(“/”),上面的showServices()方法添加@RequestMapping(value=“/service”,method=RequestMethod.GET),感谢您的回复,但应用更改后,问题仍然存在
<%@ include file="header.jsp" %>
<h1 id="carreerTitle">Carrière</h1>
<ul id="listJob">
<c:forEach items="${jobOfferList}" var="career">
<li>
<p>${career.jobTitle}</p>
<a href="/recrutement/${career.id}" class="button red-blue">Voir l'annonce</a>
</li>
</c:forEach>
</ul>
<%@ include file="footer.jsp" %>
<%@ include file="header.jsp" %>
<div id="descriptionJob">
<h2>
Description du poste
</h2>
<p>${jobOffer.jobDescription}</p>
</div>
<div id="listMissionJob">
<h2>Vos missions</h2>
<ul>
<c:forEach items="${jobOffer.jobMissionsById}" var="mission">
<li><span class="circleRed"></span>${mission}
</li>
</c:forEach>
</ul>
</div>
<%@ include file="footer.jsp" %>