简单的 div 布局呈现为不同的 jspx 编码

发布于 2024-10-30 15:40:33 字数 1298 浏览 4 评论 0原文

几天来我一直试图弄清楚当我的布局在浏览器中呈现时会发生什么。

我的环境:

  • SpringSource Tool Suite 版本:2.6.0.RELEASEtiles
  • jspx
  • + CSS
  • JavaScript InfoVis Toolkit

我的问题:

我必须从一个更大的项目中制作一个非常简单的部分,我有一个小表单来进行选择,它会触发服务器请求并获取一个 json 对象,以从 infovis 工具包(javascript)绘制空间树,该空间树绘制在表单下方,然后在选择树的节点后,它应该显示一个表格,其中包含我通过 Ajax 获得的一些信息 要求。所有这些复杂的编码就像一个魅力,问题出现在显示它的时候。所以我想做这样的事情:

<div id="1>
   <form>
</div>
<div id="2">
   <div id="infovis"></div>
   <div id="log"></div>
</div>
<div id="2">
   <table id="someID"></table>
</div>

CSS 包含一些格式,这些格式在纯 HTML 中工作得很好,

但是当部署和渲染时,我得到了类似的东西:

<div id="1>
   <form>
</div>
<div id="2">
  <div id="infovis">
     <div id="log"></div>
     <div id="2">
        <table id="someID"></table>
     </div>
     <div id="footer"></div> //this is injected cause the tiles specification
  </div>     
</div>

这个或任何其他变体。

有人遇到过类似的问题或者知道是什么原因造成的吗? spring 、tiles、脚本、jspx 实现?

我不能对其他代码或配置进行太多干扰,因为我们处于非常高级的阶段,我不想影响其他领域。

注意:我以前更多地使用 c/c++ 和实时的东西,所以我对 CSS、jsp 等不是很流利。我刚刚开始在真正的 Web 应用程序中工作。

I´ve been trying to figure out for several days what is happening to my layout when it's rendered in a browser.

my environment:

  • SpringSource Tool Suite Version: 2.6.0.RELEASE
  • tiles
  • jspx + CSS
  • JavaScript InfoVis Toolkit

my problem:

I have to make a very simple section from a bigger project where I have a small form to make a selection, it triggers a server request and gets a json object to plot a spacetree from the infovis toolkit (javascript), which is plotted below the form, and then after selecting a node of the tree it should display a table with some info that I got via an Ajax request. All this complicated coding works like a charm, the problem comes at the time to displaying it. So I want to do something like this:

<div id="1>
   <form>
</div>
<div id="2">
   <div id="infovis"></div>
   <div id="log"></div>
</div>
<div id="2">
   <table id="someID"></table>
</div>

the css contain some formatting that in plain HTML works just fine

but when deployed and rendered i got something like:

<div id="1>
   <form>
</div>
<div id="2">
  <div id="infovis">
     <div id="log"></div>
     <div id="2">
        <table id="someID"></table>
     </div>
     <div id="footer"></div> //this is injected cause the tiles specification
  </div>     
</div>

This or any other variation.

Does anybody had any similar problem or knows what can be causing it? spring , tiles, the script, the jspx implementation?

I cannot mess to much with other code or configuration because we are in a really advanced stage and I don’t want to affect other areas.

note: I used to work more with c/c++ and real-time stuff so I'm not very fluently in CSS, jsp, etc. I just started to work in real web applications.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

小鸟爱天空丶 2024-11-06 15:40:33

好吧,似乎问题出在 JSPX 解析(甚至正常的 jsp)

上,如果

内部没有“文本”,它就会消失所有

(也许还有其他标签)的

,并且由于 jspx 需要结束 > 不知何故,它会在末尾附加缺失的内容

,因此类似于

<div id="1"></div>
<div id="2"></div>

<div id="1">
    <div id="2">

然后您在浏览器中得到的是:

<div id="1">
    <div id="2">
    </div>
</div>

为了避免这种情况,您需要放置 < /code> 在必需的

之后,就像里面有文本一样,这样你就可以得到首先编码的内容。

好吧,这就是我认为它的工作原理,也许我完全错了,但不知何故它对我有用,并且当它开始出现在系统的其他部分时会节省我们的痛苦时间。你知道还有其他方法可以解决这个问题吗?或者发生这种情况的真正原因?

OK, it seems the problem was with the JSPX parsing (or even normal jsp)

somehow if the <div></div> does not have a "text" inside, it kind of takes out the </div> for all the <div> (and perhaps other tags) and since jspx need the closing </div> somehow it appends the missing ones at the end

so something like

<div id="1"></div>
<div id="2"></div>

goes to:

<div id="1">
    <div id="2">

and then what u get in the browser is:

<div id="1">
    <div id="2">
    </div>
</div>

To avoid this you need to put <jsp:text></jsp:text> after required <div> and is like you have text inside so you get what have been coded in the first place.

OK this is how I think it works, perhaps I’m completely wrong but somehow it is working for me,and will save us painful time when it start appearing in other parts of the system. do you know any other way to solve this? or the real reason why this happens?

奶茶白久 2024-11-06 15:40:33

id 属性应该有一个唯一的值(最好是数字和字母的组合)。
id 元素具有唯一值应该可以解决您的问题。

The id property should have a unique value(preferably a combination of numbers and alphabets).
Having unique value for id element should solve your problem.

听闻余生 2024-11-06 15:40:33

.jspx 文件中不能有空的 HTML 块元素:

而不是:

<div id="log"></div>

尝试

<div id="log"> </div>

You can't have empty HTML block elements in a .jspx file:

Instead of:

<div id="log"></div>

Try

<div id="log"> </div>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文