原始问题:
网页端控制stm32灯亮灭的前端html及java后端代码
前端html代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>控制stm32灯亮灭</title>
</head>
<body >
<form action="http://localhost:8080/led" method="post">
<input type="submit" name="on" value="开灯">
<input type="submit" name="off" value="关灯">
</form>
</body >
</html> 后端java代码:
import java.io.IOException; //导入IO异常处理包
import javax.servlet.ServletException; //导入servlet异常处理包
import javax.servlet.http.HttpServlet; //导入HttpServlet基本包
import javax.servlet.http.HttpServletRequest; //导入HttpServlerRequest基本包
import javax.servlet.http.HttpServletResponse;//导入HttpServlerResponse基本包
public class Led extends HttpServlet {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String on = req .getParameter("on");
String off = req .getParameter("off");
if(null != on){ System .out .println("开启LED"); }
Prev:写一部五百字的灵异故事