【问题标题】:JTSL page parameters not being evaluated - using Spring MVC + Embedded Jetty未评估 JTSL 页面参数 - 使用 Spring MVC + Embedded Jetty
【发布时间】:2010-11-26 10:27:31
【问题描述】:

我正在尝试让 Spring MVC 注释示例与嵌入式 Jetty Web 服务器一起使用,

Spring MVC 注解示例:

http://www.vaannila.com/spring/spring-annotation-controller-1.html

我的(非常基本的)网络服务器:

import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.webapp.WebAppContext;

public class ServerRunner {

    public static void main(String[] arguments) throws Exception {
        Server server = new Server();

        Connector connector = new SelectChannelConnector();
        connector.setPort(8080);

        server.addConnector(connector);

        WebAppContext webappcontext = new WebAppContext();
        webappcontext.setContextPath("/foo");
        webappcontext.setWar(".");

        server.addHandler(webappcontext);

        server.start();
        server.join();
    }
}

服务器启动正常,我去

http://localhost:8080/foo/userRegistration.htm

在我的浏览器中(使用 http)。 但是当我点击提交时,下一页显示${user.name}${user.country},而不是评估表达式本身。

JSP 源码:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!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>Success Page</title>
</head>
<body>

User Details
<hr>
User Name   : ${user.name}
Gender      : ${user.gender}
Country     : ${user.country}
About You   : ${user.aboutYou}
Community   : 
<c:forEach var="community" items="${user.communityList}" >
 ${community}
</c:forEach> <br />
Mailing List: ${user.mailingList}
</body>
</html>

Web 应用程序在 Jetty Standalone 上运行良好,但在 Embedded Jetty 下无法正常运行。 有没有人遇到过这个问题?我正在使用 Jetty 版本 6。

我的 web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"   
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" 
    version="2.5">
  <display-name>Foo</display-name>
  <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>*.htm</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>redirect.jsp</welcome-file>
    </welcome-file-list>
</web-app>

【问题讨论】:

  • 你的web.xml是什么样的?

标签: spring jstl jetty


【解决方案1】:

好的,问题是我的 JAR 文件有冲突。启动并运行带有 Spring 的嵌入式 Jetty 应用程序,您只需要以下内容:

activation-1.1.jar 蚂蚁1.6.5.jar 核心3.1.1.jar jetty-6.1.11.jar jetty-annotations-6.1.11.jar 码头命名-6.1.11.jar jetty-plus-6.1.11.jar jetty-util-6.1.11.jar jsp-2.1.jar jsp-api-2.1.jar log4j.jar mail-1.4.jar servlet-api-2.5-6.1.11.jar antlr-runtime-3.0.jar commons-logging-1.0.4.jar json.jar jstl.jar org.springframework.asm-3.0.0.M3.jar org.springframework.beans-3.0.0.M3.jar org.springframework.context-3.0.0.M3.jar org.springframework.context.support-3.0.0.M3.jar org.springframework.core-3.0.0.M3.jar org.springframework.expression-3.0.0.M3.jar org.springframework.web-3.0.0.M3.jar org.springframework.web.servlet-3.0.0.M3.jar 标准.jar

:)

【讨论】:

    猜你喜欢
    • 2012-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-12
    • 2015-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多