很郁闷,一个项目的答疑问题管理页面,当你去查看那个问题的详细内容时,内容里显示前面有<p></p>标签,即<p>内容</p>
,内容是从数据库里提取的,我怎样才能去掉内容外面的<p></p>标签呢?

解决方案 »

  1.   

    估计数据库里保存的是 &lt;&gt;   你取出来的时候替换一下么。&lt;替换为 < &gt;替换为>
      

  2.   

    用到标签的话在标签里加 escape=false/true 试试
      

  3.   

     1.你先把数据里面读出来的东西打印下 是否包含有<p>标签的 字符
      2.按理由这个标签是合法的啊 如果有也不会显示出来啊, 请把你显示查询数据的页面 发出来看看
      

  4.   

    用字符串截取<p>内容</p>,你可以用substring(2,s.length-3)试一试
      

  5.   

    还可以这样:要显示的详细内容 -> content在显示的时候这样的处理 :  HTMLEncoder  
      

  6.   

    我在struts-tags.tld文件中找到了那个标签,里面这样写的不知道是不是你想说的:<tag>
        <name>property</name>
        <tag-class>org.apache.struts2.views.jsp.PropertyTag</tag-class>
        <body-content>empty</body-content>
        <description><![CDATA[Print out expression which evaluates against the stack]]></description>
        <attribute>
          <name>default</name>
          <required>false</required>
          <rtexprvalue>true</rtexprvalue>
          <description><![CDATA[The default value to be used if <u>value</u> attribute is null]]></description>
        </attribute>
        <attribute>
          <name>escape</name>
          <required>false</required>
          <rtexprvalue>true</rtexprvalue>
          <description><![CDATA[ Whether to escape HTML]]></description>
        </attribute>
        <attribute>
          <name>id</name>
          <required>false</required>
          <rtexprvalue>true</rtexprvalue>
          <description><![CDATA[id for referencing element. For UI and form tags it will be used as HTML id attribute]]></description>
        </attribute>
        <attribute>
          <name>value</name>
          <required>false</required>
          <rtexprvalue>true</rtexprvalue>
          <description><![CDATA[Value to be displayed]]></description>
        </attribute>
      </tag>
    这个是那个标签的完整配置,红色为你说的是吗
      

  7.   

    对啊,你在strust标签里加上 escape=false/true 试试
      

  8.   

    jsp用的是struts2 标签 <s:property value="messageList[0][3]"/>你说的可能无法实现。
      

  9.   

    你是说在jsp页面的<s:property value="messageList[0][3]"/>里面加吗,我试了下,报500的错误!
      

  10.   

    用的是struts2 的标签 限于篇幅,我贴两条吧:<tr>
            <td align="center" bgcolor="#E9F4FF" class="kctx_zi1"><font color="red" size="3"></font> <strong>提问者</strong></td>
            <td align="left" bgcolor="#FAFAFA" class="kctx_zi2"  > &nbsp; <s:property value="messageList[0][1]"/></td>
            </tr>
            <tr>
            <td align="center" bgcolor="#E9F4FF" class="kctx_zi1"><font color="red" size="3"></font> <strong>提问内容</strong></td>
           <td align="left" bgcolor="#FAFAFA" class="kctx_zi2"> &nbsp; <s:property value="messageList[0][3]" /></td>
            </tr>
      

  11.   

    <s:property escape="false" value="messageList[0][3]"/>
    这样会报错? 不可能吧,肯定不是escape的问题
      

  12.   

    谢谢,问题已经解决,是刚才escape="false"我没加引号的缘故