Struts JSP页面无法正确显示,它在浏览器中显示未解析的源代码

时间:2016-01-21 14:37:31

标签: maven jsp configuration struts struts-config

我使用Tomcat 8和Struts 1.3.10

当我执行我的申请时

  

http://127.0.0.1:8080/appli/welcome.jsp

我在浏览器中有这个

  

<%@ taglib uri =“http://struts.apache.org/tags-tiles”prefix =“tiles”%>   <%@ taglib uri =“http://struts.apache.org/tags-html-el”prefix =“html”   %GT; <%@ taglib uri =“http://struts.apache.org/tags-bean-el”   prefix =“bean”%> <%@ taglib uri =“http://java.sun.com/jstl/core”   prefix =“c”%> <%@ taglib uri =“http://struts.apache.org/tags-logic-el”   prefix =“logic”%> “>”>

控制台中的消息:

  

2016-01-21 15:20:39 DEBUG ModuleUtils:171 - 获取路径的模块名称   /generic/authentification/Login.do 2016-01-21 15:20:39调试   ModuleUtils:196 - 找到模块名称:default 2016-01-21 15:20:39 DEBUG   RequestProcessor:161 - 处理路径的'GET'   '/ generic / authentification / Login'2016-01-21 15:20:39 DEBUG   TilesRequestProcessor:265 -   uri = / WEB-INF / jsp / generic / tiles / template_blank.jsp doInclude = false   2016-01-21 15:25:12 DEBUG ApplicationFilter:59 - 请求路径:   '/accueil.jsp' - 方法:GET 2016-01-21 15:25:12 DEBUG   ApplicationFilter:63 - Accesrefusé2016-01-21 15:25:12 DEBUG   ModuleUtils:171 - 获取路径的模块名称   /generic/authentification/Login.do 2016-01-21 15:25:12调试   ModuleUtils:196 - 找到模块名称:default 2016-01-21 15:25:12 DEBUG   RequestProcessor:161 - 处理路径的'GET'   '/ generic / authentification / Login'2016-01-21 15:25:12 DEBUG   TilesRequestProcessor:265 -   uri = / WEB-INF / jsp / generic / tiles / template_blank.jsp doInclude = false

怎么了?我忘了配置 有些事吗?

我的Pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.project</groupId>
    <artifactId>appli</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>appli</name>

    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>

        <!-- Applicatif -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.0.7.Final</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts-core</artifactId>
            <version>1.3.10</version>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts-extras</artifactId>
            <version>1.3.10</version>
        </dependency>

        <!-- JSP TLD -->
        <dependency>
            <groupId>net.fckeditor</groupId>
            <artifactId>java-core</artifactId>
            <version>2.6</version>
        </dependency>
        <!-- <dependency> <groupId>taglibs</groupId> <artifactId>standard</artifactId> 
            <version>1.1.2</version> </dependency> -->
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts-taglib</artifactId>
            <version>1.3.10</version>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts-el</artifactId>
            <version>1.3.10</version>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts-tiles</artifactId>
            <version>1.3.10</version>
        </dependency>

        <!-- Birt -->
        <dependency>
            <groupId>org.eclipse.birt.runtime</groupId>
            <artifactId>org.eclipse.birt.runtime</artifactId>
            <version>4.3.0</version>
            <exclusions>
                <exclusion>
                    <artifactId>org.apache.poi</artifactId>
                    <groupId>org.eclipse.birt.runtime</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.9</version>
        </dependency>

        <!-- Divers -->

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>com.novell.ldap</groupId>
            <artifactId>jldap</artifactId>
            <version>2009-10-07</version>
        </dependency>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
            <classifier>jdk15</classifier>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>javax.mail-api</artifactId>
            <version>1.5.5</version>
        </dependency>

    </dependencies>

    <build>
        <finalName>apex</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <archive>
                        <manifestEntries>
                            <Specification-Title>J2EE Servlet</Specification-Title>
                            <Specification-Version>2.5</Specification-Version>
                            <Specification-Vendor>Sun Microsystems</Specification-Vendor>
                            <Implementation-Title>${pom.name}</Implementation-Title>
                            <Implementation-Version>${pom.version}</Implementation-Version>
                            <Implementation-Vendor>${pom.organization.name}</Implementation-Vendor>
                            <Built-By>me</Built-By>
                            <Implementation-URL>${pom.url}</Implementation-URL>
                        </manifestEntries>
                    </archive>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax</groupId>
                                    <artifactId>javaee-endorsed-api</artifactId>
                                    <version>7.0</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

的welcome.jsp:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="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>Login Example</title>
</head>
<body>
    <html:form action="/login" focus="userName">
Username : <html:text property="userName" />
        <br>
Password : <html:password property="password" />
        <br>
        <html:submit value="login" />
    </html:form>
</body>
</html>

的web.xml

当我评论两条线时它全部工作但是当我取消注释这条线时我有pb

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
    <display-name>Struts Blank Application</display-name>

    <!-- Standard Action Servlet Configuration -->
    <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
            <param-name>config</param-name>
            <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
        <!-- <init-param> <param-name>chainConfig</param-name> <param-value>org/apache/struts/tiles/chain-config.xml</param-value> 
            </init-param> -->
        <load-on-startup>2</load-on-startup>
    </servlet>


    <!-- Standard Action Servlet Mapping -->
    <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>
<!--    <servlet-mapping> -->
<!--        <servlet-name>jsp</servlet-name> -->
<!--        <url-pattern>/javascript/generic/messages.js</url-pattern> -->
<!--    </servlet-mapping> -->
<!--    <servlet-mapping> -->
<!--        <servlet-name>jsp</servlet-name> -->
<!--        <url-pattern>*.css</url-pattern> -->
<!--    </servlet-mapping> -->

    <!-- The Usual Welcome File List -->
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

</web-app>

1 个答案:

答案 0 :(得分:1)

如果在jsp页面中有未解析的代码,则表示

  

JSP引擎根本没有运行

您已在action中覆盖了网络配置。因为你没有发布问题,我无法告诉你哪里错了。可能是您错误地将/* servlet映射到 <!-- Standard Action Servlet Configuration --> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <!-- Standard Action Servlet Mapping --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> 。这只是标准配置

Template.layout.events({
'click #cat': function(event) {
    event.preventDefault();

    //sets the session to a variable
    var sortBy = Session.get('sort_by');

    if (sortBy.category == 'desc') {
        return Session.set('sort_by', {
            category: 'asc'
        });
    } else {
        return Session.set('sort_by', {
            category: 'desc'
        });
    }
  }
})