为什么我的 jsp struts2 sx:textarea 仅呈现为水平条而不是预期的输入字段?

发布于 2024-10-02 05:32:22 字数 3581 浏览 4 评论 0原文

我开始尝试按照本教程创建一个富文本编辑器

我很快意识到该教程已经过时了,我需要使用 struts2-dojo-plugin。

我的 JSP 现在看起来像这样:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Pagination Example</title>
<sx:head parseContent="true"/> 
<link href="<s:url value="/assets/css/main.css"/>" rel="stylesheet" type="text/css"/>
</head>
<body>
    <s:form>
        <sx:textarea id="pasteTextInput" name="text" label="Paste your text here" cols="50" rows="50" />
    </s:form>
</body>
</html>

当我去呈现此页面时,我得到的只是一个小水平条,而不是所需的富文本编辑器,甚至任何文本区域元素。

这是相关的 CSS:

// /assets/css/main.css
#pasteTextInput
{
    background-color: #fcfcfc; 
    border: 1px solid #a0a0a0;
    min-height: 500px;
    max-height: inherit;
}

这是服务器创建的 HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Pagination Example</title>

<script language="JavaScript" type="text/javascript"> 
    // Dojo configuration
    djConfig = {
        isDebug: false,
        bindEncoding: "UTF-8"
          ,baseRelativePath: "/OverviewOfStruts/struts/dojo/"
          ,baseScriptUri: "/OverviewOfStruts/struts/dojo/"
         ,parseWidgets : true

    };
</script> 



  <script language="JavaScript" type="text/javascript"
        src="/OverviewOfStruts/struts/dojo/struts_dojo.js"></script> 

<script language="JavaScript" type="text/javascript"
        src="/OverviewOfStruts/struts/ajax/dojoRequire.js"></script> 
<link rel="stylesheet" href="/OverviewOfStruts/struts/xhtml/styles.css" type="text/css"/> 

<script language="JavaScript" src="/OverviewOfStruts/struts/utils.js" type="text/javascript"></script> 
<script language="JavaScript" src="/OverviewOfStruts/struts/xhtml/validation.js" type="text/javascript"></script> 
<script language="JavaScript" src="/OverviewOfStruts/struts/css_xhtml/validation.js" type="text/javascript"></script> 

<link href="/OverviewOfStruts/assets/css/main.css" rel="stylesheet" type="text/css"/>

</head>

<body>

    <form id="paginationExample" name="paginationExample" action="/OverviewOfStruts/paginationExample.action" method="post">

<table class="wwFormTable">

        <textarea dojoType="Editor2"
 items="linkGroup;|;textGroup;|;justifyGroup;|;listGroup;|;indentGroup;|;colorGroup"
 name="text" cols="50" rows="50" id="pasteTextInput"></textarea> 


    </table></form>









</body>

</html>

我还需要做些什么才能使其正常工作吗?

我在 本指南从 struts 2.0 更新到 struts 2.1 有关添加依赖项的内容,但我不知道在哪里添加它。 (无论它的价值如何,我使用 Maven。)

I started out trying to follow this tutorial to create a Rich Text Editor.

I quickly realized that the tutorial was outdated and I needed to use the struts2-dojo-plugin.

My JSP now looks like this:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Pagination Example</title>
<sx:head parseContent="true"/> 
<link href="<s:url value="/assets/css/main.css"/>" rel="stylesheet" type="text/css"/>
</head>
<body>
    <s:form>
        <sx:textarea id="pasteTextInput" name="text" label="Paste your text here" cols="50" rows="50" />
    </s:form>
</body>
</html>

When I go to render this page, instead of the desired rich text editor, or even any text area element, all I get is a little horizontal bar.

This is the relevant CSS:

// /assets/css/main.css
#pasteTextInput
{
    background-color: #fcfcfc; 
    border: 1px solid #a0a0a0;
    min-height: 500px;
    max-height: inherit;
}

and this is the HTML that is created by the server:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Pagination Example</title>

<script language="JavaScript" type="text/javascript"> 
    // Dojo configuration
    djConfig = {
        isDebug: false,
        bindEncoding: "UTF-8"
          ,baseRelativePath: "/OverviewOfStruts/struts/dojo/"
          ,baseScriptUri: "/OverviewOfStruts/struts/dojo/"
         ,parseWidgets : true

    };
</script> 



  <script language="JavaScript" type="text/javascript"
        src="/OverviewOfStruts/struts/dojo/struts_dojo.js"></script> 

<script language="JavaScript" type="text/javascript"
        src="/OverviewOfStruts/struts/ajax/dojoRequire.js"></script> 
<link rel="stylesheet" href="/OverviewOfStruts/struts/xhtml/styles.css" type="text/css"/> 

<script language="JavaScript" src="/OverviewOfStruts/struts/utils.js" type="text/javascript"></script> 
<script language="JavaScript" src="/OverviewOfStruts/struts/xhtml/validation.js" type="text/javascript"></script> 
<script language="JavaScript" src="/OverviewOfStruts/struts/css_xhtml/validation.js" type="text/javascript"></script> 

<link href="/OverviewOfStruts/assets/css/main.css" rel="stylesheet" type="text/css"/>

</head>

<body>

    <form id="paginationExample" name="paginationExample" action="/OverviewOfStruts/paginationExample.action" method="post">

<table class="wwFormTable">

        <textarea dojoType="Editor2"
 items="linkGroup;|;textGroup;|;justifyGroup;|;listGroup;|;indentGroup;|;colorGroup"
 name="text" cols="50" rows="50" id="pasteTextInput"></textarea> 


    </table></form>









</body>

</html>

Is there something else I need to do for this to work?

I saw on this guide to updating from struts 2.0 to struts 2.1 something about adding dependencies, but I couldn't figure out where to add this. (For whatever its worth, I'm NOT using Maven.)

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

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

发布评论

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

评论(1

银河中√捞星星 2024-10-09 05:32:22

我发现:它这样做是因为我使用的是 Chrome。

它在不同浏览器中的呈现方式非常不同,并且在 Firefox 和 Internet Explorer 中的呈现效果要显着提高。

对于所见即所得文本编辑器来说,使用它似乎是一个非常糟糕的解决方案。

肯的​​解决方案似乎要好得多。

I figured it out: it is doing that because I am using Chrome.

It renders very differently in different browsers, and considerably more effectively in Firefox and Internet Explorer.

It seems that using this is a really bad solution for a WYSIWYG text editor.

Ken's solution seems much better.

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