我正在学习Java (在WildFly服务器上使用Intellij ),并遇到了下一个问题:
我在MVC中工作,老师给了我们一个MVC模板。模板本身工作得很好,但是如果我包含了一个新的JSP页面,它就不会出现在浏览器中。浏览器将只显示如下路径:

但是,默认的“hello world”正在工作(但是否有特定的原因使用路径?):

这让我思考这是否与MVC-spring编程方法有关?但是为什么student.jsp没有出现呢?我试图在默认的欢迎页面中做一个href,用于重定向到它进行测试,但是它仍然给了我相同的‘错误’。
我在这里做错什么了?我觉得问这个问题有点尴尬,因为这看起来是一个非常简单的问题,特别是因为我还没有找到任何相关的线索。
student.jsp页面本身是正确的,我知道:
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<html>
<head>
<title>Spring MVC Form Handling</title>
</head>
<body>
<h2>Student Information</h2>
<form:form method="POST" action="addStudent">
<table>
<tr>
<td><form:label path="name">Name</form:label></td>
<td><form:input path="name" /></td>
</tr>
<tr>
<td><form:label path="age">Age</form:label></td>
<td><form:input path="age" /></td>
</tr>
<tr>
<td><form:label path="id">id</form:label></td>
<td><form:input path="id" /></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Submit"/>
</td>
</tr>
</table>
</form:form>
</body>
</html>发布于 2016-01-10 18:37:48
您不能在任何春季项目中运行一个.jsp文件。您只能在spring框架中运行项目。因此,当您包含一个新的JSP页面时,它不会出现在浏览器中。
如果您想要运行您的.jsp文件,那么您必须运行您的SpringMVCTemplate项目,而不仅仅是一个文件;2)所包含的.jsp文件必须使用SpringMVCTemplate,而不仅仅是一个简单的"hello“文件。
希望它有帮助:)
https://stackoverflow.com/questions/34701887
复制相似问题