Java 使用HTML表单使用${param.xxx}无法访问JSP参数
下面是关于Udemy的一个教程,它解释了jsp和servlet: 本教程使用Eclipse+Tomcat服务器 因为我是IntelliJ和Maven用户,所以我想使用这两种工具来设置我的环境。因此,我从以下原型创建了一个Maven项目:“org.apache.Maven.archetypes:Maven ArchetypeWebApp”,并将我的POM配置如下:Java 使用HTML表单使用${param.xxx}无法访问JSP参数,java,maven,jsp,tomcat,intellij-idea,Java,Maven,Jsp,Tomcat,Intellij Idea,下面是关于Udemy的一个教程,它解释了jsp和servlet: 本教程使用Eclipse+Tomcat服务器 因为我是IntelliJ和Maven用户,所以我想使用这两种工具来设置我的环境。因此,我从以下原型创建了一个Maven项目:“org.apache.Maven.archetypes:Maven ArchetypeWebApp”,并将我的POM配置如下: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="h
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>SomeGroupId</groupId>
<artifactId>HelloWorldJavaServerPages</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>HelloWorldJavaServerPages Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>HelloWorldJavaServerPages</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>Tomcat85Localhost</server>
<username>admin</username>
<password>admin</password>
</configuration>
</plugin>
</plugins>
</build>
</project>
4.0.0
SomeGroupId
我能够构建我的项目并使用tomcat插件部署到tomcat服务器(或者手动将war文件拖到webapps文件夹中)
问题是,当我有以下两个文件时:
student-form.html
<html>
<head><title>Student Registration Form</title></head>
<body>
<form action="student-response.jsp">
First name: <input type="text" name="firstName" />
<br/>
Last name: <input type="text" name="lastName" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
学生登记表
名字:
姓氏:
student-response.jsp
<html>
<head><title>Student Confirmation Title</title></head>
<body>
The student is confirmed: <%= request.getParameter("firstName")%> ${param.lastName}
</body>
</html>
学生确认书名
学生已确认:${param.lastName}
request.getParameter方法可以工作,但是${param.lastName}不能工作,它只是在浏览器中以纯文本显示:${param.lastName}
使用Eclipse(不使用Maven)两者都可以,所以我想知道我在这里做了哪些不同/错误的事情,以及为什么它不起作用
提前感谢您的帮助。一旦我发现大括号之间的引用称为“表达式语言”,我决定在stackoverflow上进行另一次搜索,并发现以下内容:
如上面链接中所述更改web.xml使其正常工作
谢谢大家阅读我的问题,答案其实很简单