问题描述:
前台跳转到controller执行完业务之后,controller跳转到前台的jsp页面(jsp页面可以正确访问),但是前台jsp页面所有使用相对路径引用的资源路径都发生了错误,所有资源的路径前面都添加上了一个controllerKey,导致资源无法正常访问。
controller返回试图使用绝对路径
controller
public void index() { //查询游戏数据 Integer gameId = getParaToInt("gameId"); String iptvName = getSessionAttr("iptvName"); if(gameId != null && iptvName != null){ User user = User.dao.queryUserByIPTVName(iptvName); Game game = Game.dao.queryGameById(gameId); Integer userId = user.get("u_id"); System.out.println("GameDetailController------gameId=" + gameId); System.out.println("GameDetailController------userId=" + userId); System.out.println("GameDetailController------game=" + game.toString()); System.out.println("GameDetailController------UserCollection=" + UserCollection.dao.queryUserCollectionById(userId, gameId).toString()); setAttr("isCollection", UserCollection.dao.queryUserCollectionById(userId, gameId) != null ? true : false); setAttr("game", game); } renderJsp("/gameDetail.jsp"); }
路由配置
@Override public void configRoute(Routes me) { me.add("/index", IndexController.class); me.add("/user", UserController.class); me.add("/userCollection", UserCollectionController.class); me.add("/gameDetail", GameDetailController.class); }
jsp页面
<div class="article-btn00"><img id="btn00" src="images/gameDetail/btn-collection01.png" alt=""></div> <div class="article-btn01"><img id="btn01" src="images/gameDetail/btn-play01.png" alt=""></div> <div class="article-btn02"><img id="btn02" src="images/gameDetail/btn-back01.png" alt=""></div>
错误内容:
项目:JFinal