<% for(int i=0;i<list.size();i++){ Users user=usersDao.getUsersById(list.get(i).getUserId()); ShortMess shortMess=list.get(i); HashMap<String,Image> map=imgDao.getImagesList(0); while(shortMess.getContent().indexOf("//")!=-1){ int index=shortMess.getContent().indexOf("//"); if(index!=shortMess.getContent().length()-2){ String check=shortMess.getContent().substring(index,index+4); if(map.containsKey(check)){ Image img=map.get(check); shortMess.getContent().replace(check,"<img src='"+img.getPath()+"' >"); } } } %> <div><br><img src="../images/iboy.gif"></img> <%=user.getUserName() %> <strong>:</strong><br> <%=shortMess.getContent() %></div> <%} %> 我想循環(huán)將帶“//”的那些字符替換成圖片。。可是不行誒!不要while循環(huán)的時(shí)候能有東西顯示,,,可是加了while循環(huán)就不行。。 在replace的時(shí)候并沒有將那些字符替換掉! 請(qǐng)問有哪位知道怎么解決這個(gè)問題沒有?
以下這個(gè)問題,麻煩幫忙解釋一下!關(guān)于在JSP中replace的用法?
慕勒3428872
2021-06-30 11:07:36