java jsp过时了_java – Spring不断返回字符串而不是jsp / html内容

我试图了解整个

Spring框架.据我所知,使用gradle的相对较新的技术使很多教程和帖子在线过时了?

我运行的主要问题是当我尝试显示jsp或html页面时,网页的正文显示文本:“filename.jsp”.

该项目由New->创建.其它 – >使用Gradle和STS 3.7的Spring Starter项目.

目标是使用MVC模式创建Web应用程序.

文件夹结构:

测试

– 春天元素(由STS创建)

–src /主/ JAVA

– 测试

–TestApplication.java(由STS创建)

–TEST.Controller

–JSPController.java

–sec /主/资源

–application.properties(由STS创建,EMPTY文件)

–src / main / webapp(**我创建了这个目录,但是这是必需的吗?)

–Web-INF

–home.jsp

–home.html

–web.xml(**下面的附加问题)

TestApplication.java

package TEST;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication

public class TestApplication {

public static void main(String[] args) {

SpringApplication.run(TestApplication.class, args);

}

}

针对home.jsp

pageEncoding="ISO-8859-1"%>

Test

Test 1

First name:

Last name:

JSPController.java

package TEST.controller;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;

import org.springframework.web.bind.annotation.RestController;

@RestController

public class JSPController {

@RequestMapping(value = "/jsp", method = RequestMethod.GET)

public String home(){

return "/webapp/WEB-INF/home.jsp";

}

}

web.xml中

//empty file right now

的build.gradle

buildscript {

ext {

springBootVersion = '1.2.5.RELEASE'

}

repositories {

mavenCentral()

}

dependencies {

classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")

classpath("io.spring.gradle:dependency-management-plugin:0.5.1.RELEASE")

}

}

apply plugin: 'java'

apply plugin: 'eclipse'

apply plugin: 'idea'

apply plugin: 'spring-boot'

apply plugin: 'io.spring.dependency-management'

jar {

baseName = 'TEST'

version = '0.0.1-SNAPSHOT'

}

sourceCompatibility = 1.8

targetCompatibility = 1.8

repositories {

mavenCentral()

}

dependencies {

compile("org.springframework.boot:spring-boot-starter-web")

testCompile("org.springframework.boot:spring-boot-starter-test")

}

eclipse {

classpath {

containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')

containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'

}

}

task wrapper(type: Wrapper) {

gradleVersion = '2.3'

}

当我去http://localhost:8080/jsp,

html页面有正文:/webapp/WEB-INF/home.jsp

所以jsp根本没有显示.我已经尝试过html,有或没有方法= RequestMethod.GET / POST.什么都行不通.

**其他问题:

许多在线帖子/教程都会使用.xml文件,例如web.xml.根据我的理解,不再需要或不需要这些,因为spring gradle会自动从@notations生成.xml?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值