使用Jetty和Gradle时如何解决“JSP支持未配置”

时间:2014-07-30 15:58:25

标签: jsp gradle jetty

我尝试使用gradle + jetty启动新的Web应用程序。当我在浏览器中运行gradle jettyRunWar并打开页面时,我得到了

HTTP ERROR 500

Problem accessing /WEB-INF/view/home.jsp. Reason:

    JSP support not configured

Powered by Jetty://

有什么建议吗?

我有父母和子女的项目。 Web的gradle.build文件是:

apply plugin: 'war'
apply plugin: 'jetty'

dependencies {
    compile project(':fbv-services')

    compile project(':fbv-model')

    compile "org.springframework:spring-webmvc:$springVersion"

    compile "org.springframework.security:spring-security-web:$springSecurityVersion",
            "org.springframework.security:spring-security-config:$springSecurityVersion"

    providedCompile 'javax.servlet:servlet-api:2.5'

    runtime 'javax.servlet:jstl:1.1.2'
}

jettyRunWar {
    contextPath = ''
    httpPort = 8078
    stopPort = 9078
    stopKey = 'stop'
}

jettyStop {
    stopPort = 9078
    stopKey = 'stop'
}

父gradle.build:

ext {
    springVersion = "4.0.6.RELEASE"
    springSecurityVersion = "3.2.4.RELEASE"
    slf4jVersion = "1.5.8"
}

allprojects {
    apply plugin: 'idea'

    group = 'net.vosta.fbvideo'

    version = '1.0-SNAPSHOT'
}

subprojects {
    apply plugin: 'java'

    repositories {
        mavenLocal()
        mavenCentral()
    }

}

main.jsp文件非常简单:

<!DOCTYPE HTML>
<html>
<head>
    <title>Feedback Video</title>
</head>
<body>
<h1>Hello from ${name}!</h1>
</body>
</html>

web.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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">

  <servlet>
    <servlet-name>fbvideo</servlet-name>
    <servlet-class>
        org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/spring/spring-servlet.xml</param-value>
    </init-param>
  </servlet>

  <servlet-mapping>
    <servlet-name>fbvideo</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>

</web-app>

spring-servlet.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
  http://www.springframework.org/schema/mvc    http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
  http://www.springframework.org/schema/context    http://www.springframework.org/schema/context/spring-context-3.2.xsd">

  <context:component-scan base-package="net.vosta.fbvideo" /> 
  <mvc:annotation-driven />

  <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/view/"/>
    <property name="suffix" value=".jsp"/>
  </bean>

</beans>

0 个答案:

没有答案