开发者

Struts2 - First Steps - My page doesnt get the right css

开发者 https://www.devze.com 2023-01-28 18:43 出处:网络
Hi making my first page using Struts2. This is the easy code : <%@ taglib prefix=\"s\" uri=\"/struts-tags\" %>

Hi making my first page using Struts2.

This is the easy code :

<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link rel="stylesheet" type="text/css" href="css/interfaccia.css" />
        <link rel="stylesheet"开发者_JS百科 type="text/css" href="css/links.css" />
        <link rel="stylesheet" type="text/css" href="css/fonts.css" />
        <link rel="stylesheet" type="text/css" href="css/profile.css" />
        <link rel="stylesheet" type="text/css" href="css/affitta.css" />

        <title>
                Struts2 - The Sinfonet Portal
        </title>
    </head>

    <body>

        <s:div cssStyle="contenitore">
            <s:div cssStyle="header">
                <s:div cssStyle="header1">
                    <img src="img/logosw.png" alt="Logo Sinfonet" />
                </s:div>

                <s:div cssStyle="header2">
                    <img src="img/band1.jpg" alt="Flag 1" class="photoband" />
                    <img src="img/band2.jpg" alt="Flag 2" class="photoband" />
                    <img src="img/band3.jpg" alt="Flag 3" class="photoband" />
                </s:div>
            </s:div>

            <s:div cssStyle="center">
                <s:div cssStyle="menu">
                    <s:div cssStyle="menu_table">
                        <s:label cssStyle="menu_title" value="Login" />
                        <s:label cssStyle="menu_span" value="Username" />
                        <s:textfield />
                        <s:label cssStyle="menu_span" value="Password" />
                        <s:textfield />
                    </s:div>
                </s:div>
            </s:div>
        </s:div>
    </body>
</html>

I don't know why it doesnt get the right CSS style (in fact the page looks strange).

What am I wrong?


Have you checked that all of your CSS files are served properly (i.e., they aren't resulting in 404 errors)?


You could try out your page with <div instead of <s:div and see what you get.


I was having a same problem, after parsing through struts css seem to vanish.

Solution: Just add folder name before style in href.

e.g:

Before:

href="style.css"

After:

href="foldername/style.css"


Seems to be nothing Struts2-specific. As Steven answered, check that you get the css-files served if you enter the URL they should be at directly. If not, it may be that you'll have to take a look in your WebContent/WEB-INF/web.xml file if you're directing the requests wrong.


Try something like this

<link href="<s:url value="css/interfaccia.css"/>" rel="stylesheet" type="text/css"/>


You Have to mention the whole path in every page

like..

<link rel="stylesheet" type="text/css" href="<s:url value="/css/style.css" />" />

for images

<img id="logo" src="<s:url value="/images/logo.png" />" />

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号