第一个普通的javaWeb工程
步骤以下
1.在sts中新建一个Dynamic Web Project
2.在src下新建package与class
3.在WebContent下新建jsp文件
工程目录结构以下
test.jsp文件以下html
<%@page import="com.test.javaweb.Car"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <% Car car = new Car(); System.out.println(car.getCarInfo()); %> </body> </html>
4.运行工程,在浏览器输入
http://localhost:8080/TestJavaWeb/test.jsp
结果
在控制台输出 Audi。 该test.jsp的功能很简单,在控制台打印car.getCarInfo()的消息便可。java