我有一个部署到Jboss 6.4的简单Spring启动应用程序。但是JSP呈现为文本:以下是有关应用程序的一些细节:
Pom文件依赖项
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
WebMvcConfig文件具有以下方法:
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import rg.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
@Configuration
@EnableWebMvc
public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Override
public void configureDefaultServletHandling(
DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
@Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setViewClass(org.springframework.web.servlet.view.JstlView.class);
resolver.setPrefix("WEB-INF/jsp/");
resolver.setSuffix(".jsp");
return resolver;
}
JSP文件:
<!DOCTYPE html>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<html>
<head>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
</head>
<body>
Message: Test Message
</body>
</html>
但是一旦通过Jboss部署和访问,屏幕上显示的内容就是:
&lt;%@ taglib uri =&#34; http://www.springframework.org/tags"前缀=&#34;弹簧&#34;%GT; &lt;%@ taglib uri =&#34; http://java.sun.com/jstl/core_rt"前缀=&#34; C&#34; %GT; &lt;%@ page language =&#34; java&#34;的contentType =&#34; text / html的;字符集= UTF-8&#34;的pageEncoding =&#34; UTF-8&#34;%GT;消息:测试消息
如果你们中的任何人遇到过将Spring Boot部署到jboss中的问题以及是否有任何解决方法,请告诉我。
提前谢谢!