怎么在在页面显示上传的代码,代码中含有一些html,js等 1C
   <script src="static/toastr/toastr.js" type="text/javascript"></script>
    <title>IT世家--首页</title>
    <script type="text/javascript">
        var basePath = "${BASE_PATH}";
    </script>
</head>
<body>
    <!-- 被拦截器拦截时显示 -->
    <div class='Alt'>
        <jsp:include page="/WEB-INF/pages/common/login.jsp"></jsp:include>
    </div>
    <div class="popup_mask" style="display: none;" onclick='shouqi()'></div>

<a href='' id='mao'></a>
           <div class="headhome">
               <div class="homeflow">
                   <div class="homebg">
                       <div class="md">
                           <div class="fr conbar" style="position: relative;" >
                                <c:if test="${not empty FRONT_LOGIN_USER }">
                                    <a class="col userLogin aaa" style="position: relative;cursor: pointer;" >
                                        <c:if test="${not empty FRONT_LOGIN_USER.TUserVcard.avatar }">
                                            <img src='${BASE_PATH}${FRONT_LOGIN_USER.TUserVcard.avatar }' class="loginName" />
                                        </c:if>
                                        <c:if test="${empty FRONT_LOGIN_USER.TUserVcard.avatar }">
                                            <img src='static/images/reg_user.png' class="loginName"/>
                                        </c:if>
                                        ${FRONT_LOGIN_USER.TUserVcard.nickName }<span class='Indexmessage'></span>
                                    </a> 
                                </c:if>
                                    <ul class="userLogin caidan" style='width: 80%;'>
                                        <li class='home' onclick="window.location.href='${BASE_PATH}homepage/homepage'">
                                            <img src="static/images/user_head_icon.png" class='img1' />
                                            <img src="static/images/user_head_icon2.png" class='img2' />
                                            <a href='javascript:;'>我的主页</a></li>
                                        <li class='info'  onclick="window.location.href='${BASE_PATH}notify/index'" style="position: relative;">
                                            <img src="static/images/user_info_icon.png" class='img1' />
                                            <img src="static/images/user_info_icon2.png" class='img2' style='padding-top: 3px;' />
                                            <a href='javascript:;'>消息<span id="indexMessage" class="nav-counter" style="margin-left: 5px;"></span></a>
                                        </li>
                                        <li class='set' onclick="window.location.href='${BASE_PATH}user/toSet'">
                                            <img src="static/images/user_set_icon.png" class='img1' />
                                            <img src="static/images/user_set_icon2.png" class='img2' /><a href='javascript:;'>设置</a></li>
                                        <li class='out' onclick="window.location.href='${BASE_PATH}login/exitLogin'">
                                            <img src="static/images/user_out_icon.png" class='img1' />
                                            <img src="static/images/user_out_icon2.png" class='img2' /><a href='javascript:;'>退出</a></li>
                                    </ul>

                                <c:if test="${empty FRONT_LOGIN_USER }">
                                    <a href="login/index" class="col dengl">登录</a> 
                                    <a href="login/index?registerFlag=1" class="col zhuc">注册</a> 
                                </c:if>

                               <a href="login/help" class="col bangz" target="_blank">帮助</a>

                           </div>
                           <div class="clear">
                           </div>
                           <div class="logo" style='padding-top: 45px;'>
                               <a>
                                <!-- LOGO -->
                                <img alt="IT世家" src="static/images/logo.png" style='width:120px;height: 90px;'>
                               </a>
                           </div>
                           <div class="zbtn">
                                <a href="sourcecode/toAdd" target="_blank">
                                    <div class="hbtn">上传源码</div>
                                </a>
                                <a href="question/toAdd" target="_blank">
                                    <div class="hbtn">我要提问</div>
                                </a>
                           </div>
0

4个回答

0
 将html代码中的<>替换为实体&lt;&gt;就可以显示了,要不直接输出html标签会被解析而不是显示出来。当然也可以用textarea做容器,但是html代码包含</textarea>是要替换掉
0

唯一需要注意的就是标签的转化

0

可以把内容 用jquery 的 html() 和 text() 方法转化一下

0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!