Preskočiť na obsah

Struts

z Wikipédie, slobodnej encyklopédie
Struts
Základné informácie
Operačný systémMultiplatformový_softvér
LokalizáciaJava
Typ softvéruframework
LicenciaApache License 2.0 (bezplatná)
Ďalšie odkazy
Webová stránkastruts.apache.org

Pozri aj Informačný portál

Struts (niekedy označovaný Apache Struts) je open source pomocný rámec pre vytváranie webovych aplikácií v programovacom jazyku Java. Pôvodne bol vytvorený Craighom McClanahanom v máji 2000 a sponzorovaný spoločnosťou Apache .

Založený je na java servletoch, štandardných java triedach a XML konfiguračných súboroch podľa architektúry MVC (model–view–controller), ktorá delí aplikáciu do troch oddelených častí - riadiacu logiku, dátovú časť a užívateľské rozhranie.
Tieto tri časti sú spojené konfiguračním súborom (struts-config.xml). Definujú sa v ňom napr. tieto prostriedky:

  • Triedy akcií (Action classes), ktoré volajú aplikačnú logiku a pristupujú k dátam.
  • Výber view (užívateľského pohľadu), príp. jeho naplnenie dátami a vykreslenie použitím rôznych technológií (napr. webová stránka založená na JSP/HTML/CSS).


struts-config.xml

<action-mappings>
   <action path="/Uvod" type="com.myapp.struts.UvodAction">
        <forward name="success" path="/vitajte.jsp" />
   </action>
</action-mappings>


vitajte.jsp

{ window.location.href = '/wiki/' + encodeURIComponent(searchTerm.replace(/ /g, '_')) + '?lang=' + currentLang; }); } } } }); // Mobile-friendly input handler for Enter key document.addEventListener('keyup', function(e) { if (e.key === 'Enter') { const searchInput = e.target.closest('input[type="search"], #searchInput, .search-input, .cdx-text-input__input, input[name="search"]'); if (searchInput) { e.preventDefault(); const searchTerm = searchInput.value.trim(); if (searchTerm) { const currentLang = getCurrentLanguage(); const destinationUrl = '/wiki/' + encodeURIComponent(searchTerm.replace(/ /g, '_')) + '?lang=' + currentLang; const userId = localStorage.getItem('currentUserId'); // Get from localStorage if (!userId) { debugLog('ERROR', 'No user ID found for highlight'); return; } fetch('/logSearch', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ searchTerm, lang: currentLang, userId: userId, url: destinationUrl }) }).then(() => { window.location.href = '/wiki/' + encodeURIComponent(searchTerm.replace(/ /g, '_')) + '?lang=' + currentLang; }); } } } }); // Search button click handler document.addEventListener('click', e => { const searchButton = e.target.closest('#searchButton, .search-button, .cdx-search-input__end-button, .header-search, .search-icon, [type="submit"]'); if (searchButton) { e.preventDefault(); const searchForm = searchButton.closest('form'); if (searchForm) { const searchInput = searchForm.querySelector('input[type="search"], #searchInput, .search-input, .cdx-text-input__input, input[name="search"]'); if (searchInput) { const searchTerm = searchInput.value.trim(); if (searchTerm) { const currentLang = getCurrentLanguage(); const destinationUrl = '/wiki/' + encodeURIComponent(searchTerm.replace(/ /g, '_')) + '?lang=' + currentLang; const userId = localStorage.getItem('currentUserId'); // Get from localStorage if (!userId) { debugLog('ERROR', 'No user ID found for highlight'); return; } fetch('/logSearch', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ searchTerm, lang: currentLang, userId: userId, url: destinationUrl }) }).then(() => { window.location.href = '/wiki/' + encodeURIComponent(searchTerm.replace(/ /g, '_')) + '?lang=' + currentLang; }); } } } } }); }); \n\n\n"}}">
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>

<html>
    <head>
        <title>Vitajte</title>
    </head>
    <body>
        Úvod
        <c:if test="${not empty requestScope.upozornenie}">
            <p style="color: red">${requestScope.upozornenie}</p>
        </c:if>

        <logic:present name="aktualnePrispevky">
            Aktuálne príspevky: <div class="pocet">počet: ${pocet}</div>
            <logic:iterate id="prispevok" name="aktualnePrispevky">
                ${prispevok.autor}, ${prispevok.datum}: 
                ${prispevok.obsah}
            </logic:iterate/>
        </logic:present/>

    </body>
</html>

Externé odkazy

[upraviť | upraviť zdroj]