【高级网络程序设计】Week3-2 Servlet

news2025/5/25 7:20:21

一、 What are servlets?

1. 定义

(1)Servlets are Java’s answer to CGI:

programs that run on a web server acting as middle layer between HTTP request and databases or other applications.
Used for client requests that cannot be satisfied using pre-built (static) documents.
Used to generate dynamic web pages in response to client.

(2)图解

Web BrowserSending Requests to a Web Server
Web Server

hold/return static web pages

– e.g. index.html does not respond to user input.

Server Side Programs

different technologies written in various languages

 – e.g. CGI scripts, Java Servlets (and JSPs – later), PHP scripts
 – Call to http://localhost:8080/servlet/myhelloservlet.HelloServlet
 – Not web-browsing but executing program (servlet)
Dynamic response– database lookup, calculation etc.
We’ll look at the Java solutionhow to write servlets; how the container (Tomcat) works.

2. A general purpose Web Server

二、Simple Example

ignore how the Container finds the servlet (via the deployment descriptor web.xml).
<form action=“http://server.com/ExecuteServlet”>
<input type=“submit” value = “press for servlet”>
</form>

1.  A Basic Servlet

import jakarta.servlet.*;
import jakarta.servlet.http.*;
import java.io.*;
//import jakarta.servlet.*:imports classes in this directory, but not in sub-directories
public class HelloServlet extends HttpServlet {
    public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
        response.setContentType("text/html");//设置响应文件类型、响应式的编码形式
        PrintWriter out = response.getWriter();//获取字符输出流
        out.println(“<html><body>Hello!</body></html>”);
        out.close();
    }
}

2.  Echo Servlet

import jakarta.servlet.*;
import jakarta.servlet.http.*;
import java.io.*;
public class GetEchoServlet extends HttpServlet {
    public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException, ServletException {
        String userName = request.getParameter(“fname”);//获取form中输入的参数
        response.setContentType("text/html");//设置响应文件类型、响应式编码格式
        PrintWriter out = response.getWriter();//获取字符输出流
        out.println(“<html><body>Hello”);
        if (userName != null) 
            out.println(userName);
        else 
            out.println(“mystery person”);
        out.println(“</body></html>”);
        out.close();
    }
}

3. BMI Servlet

- HTML
//Page that asks for weight (kg) and height (cm) :Write the HTML and the HTTP Request (GET)
<form method=“GET”action=“http://server.com/BMIServlet”>
<input type=“text” name=“weight”/>weight<br>
<input type=“text” name=“height”/>height<br>
<input type=“submit” value=“send”>
</form>

- Servlet


import jakarta.servlet.*;
import jakarta.servlet.http.*;
import java.io.*;
public class BMIServlet extends HttpServlet {
    public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException {
        String ht = request.getParameter(“height”);
        int height = Integer.parseInt(ht);
        double weight = Double.parseDouble(request.getParameter(“weight”));
        double ht_squared = (height/100.0)*(height/100.0);
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println(“<html><body><br>”);
        out.println(“Your BMI is: ” + weight/ht_squared + “<body></html>”);
        out.close();
    }
}

4. Name-salary Servlet

import jakarta.servlet.*;
import jakarta.servlet.http.*;
import java.io.*;
public class HelloServlet extends HttpServlet {
    public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
        String name = request.getParameter("name");
        int salary = Integer.parseInt(salary);
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<html><body><br>");
        out.println("Hello,"+name);
        out.println("Your salary is"+salary);
        out.println("<body><html>");
        out.close();
    } // end of method
} // end of class

三、Servlet Key Points

1. Servlets: Key points

NO main method public static void main(String[] args)
NO constructor

There is one (default) constructor but the developer should never write an explicit constructor

 – Why——servlet lifecycle

Two key (service) methodsdoGet(); doPost()

2. Finding things

Tracing the user data
– e.g. name attribute inside an HTML element
– name in HTTP request message
– argument in request.getParameter(...)
 String(int/double required)

then have to use appropriate method on this String to convert

- Integer.parseInt();

- Double.parseDouble();

Finding the servlet
<form> tag action attribute e.g. <FORM action=“servlet/myServlet” ...>
– Used by deployment descriptor, web.xml (see later), to map to the corresponding servlet class.

3. JavaBeans, JSPs and Servlets

Although a servlet can be a completely self-contained program, to ease server-side programming, generating content should be split into
The business logic (content generation), which governs the relationship between input, processing, and output.
The presentation logic (content presentation, or graphic design rules), which determines how information is presented to the user.
controllerthe servlet handles the HTTP protocol and coordination of which other servlets and auxiliary class methods to call
modelJava classes/JavaBeans handle the business logic
viewJava Server Pages handle presentation logic

4. Advantages of Servlets over CGI

Efficient
– Servlets run in the JVM. Each request is serviced using a thread rather than a new process (so lower overhead).
- Though some scripting languages, e.g. perl on certain web servers do this now.
Convenient– Provides infrastructure that parses and decodes HTML forms.
Powerful
– Can communicate directly with web server.
– Multiple servlets can share database connections.
– Simplifies session tracking.
Portable– Written in Java and follows standard API.
Secure
– CGI often executed using O/S shells, which can cause many security breaches.
– Array checking & exception handling is automatic in Java.
Inexpensive
– Many Java web servers are freely available.

四、Servlets in Detail

1. A general purpose Web Server

2. What servlets do

 requestRead any data sent by the user
Look up information embedded in HTTP request
Generate results.
response
Format results inside a document (e.g. HTML, XML, GIF, EXCEL).
Set appropriate HTTP response parameters.
Send the document back to the client.

3. Typical generic servlet code

import java.io.*;
import jakarta.servlet.*;
public class AnyServlet extends GenericServlet {
    public AnyServlet() {} 
        // constructor – BUT USE THE DEFAULT
        // NEVER ANY NEED TO WRITE ONE
        //ONLY creates an object, becomes a “proper” servlet after init().
    public void init(ServletConfig config) throws ServletException;
        // The method is actually called by container when servlet is
        // first created or loaded.
    public void service(ServletRequest req, ServletResponse res)throws ServletException, IOException;
        // Called by a new thread (in the container) each time a
        // request is received.
        public void destroy();
        // Called when servlet is destroyed or removed.
}

4. A Servlet is “deployed” in a container

• A program that receives (e.g. HTTP) requests to servlets from a web server application:
– finds the servlet (and loads, calls constructor & init() if not ready);
– creates or reuses a thread that calls service() method of chosen servlet;
– creates & passes request and response objects to chosen servlet;
– passes the response (e.g. HTTP response) back to the web server application; kills servlet thread or recycles into thread pool; and deletes request and response objects.
• More generally, manages the life cycle of its servlets:
Calls constructor, init(), service(), destroy().
– Also invokes methods of listening classes that a servlet implements (out of scope here).
• It has a main() and is working “all the time”.
• Also provides:
– Declarative security using settings in Deployment Descriptor (DD).
– JSP support.

5. Dissecting the Container’s actions

- HTTP request:
GET   /myServlet/BMIInfo   height=156&name=paula+fonseca   HTTP/1.1
- Servlet:
public class BMIServlet extends HttpServlet {
        public void doGet(HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException {
                // ...
                String ht = request.getParameter(“height”);
                // ...
        }
}

6. The servlet life cycle

7. methods & inheritance

8. Servlet’s Life cycle

Constructor (no arguments)
– not written or called by a developer
– called by the container
public void init()
– called after constructor
– called once, at the beginning (so potentially useful for initialisation of, e.g. databases)
– can be overridden by the developer
public void service(…)
rarely overridden by thedeveloper
– called everytime

public void doGet() /

public void doPost()

must be written by the developer
– must match the HTTP method in <form> in the HTML
public void destroy()

– must be written by the developer

五、 Configuration Servlets To Run In Tomcat

1. Mapping names using the Deployment Descriptor (DD)

//For each servlet in the web application.
//Internal name of servlet can be “anything” following XML rules.
<web-app ...>
    <servlet>
        <servlet-name>…</servlet-name>
        //maps internal name to fully qualified class name (except without .class)
        <servlet-class>…</servlet-class>
        //maps internal name to public URL name e.g. /makebooking
    </servlet>
    <servlet-mapping>
        <servlet-name>…</servlet-name>
        <url-pattern>…</url-pattern >
    </servlet-mapping>
...
</web-app>

2. Servlet Mapping Examples

- HTML:
<FORM method=“post” action=“/servlet/MyTest.do”>
- Server (webapps):
WEB-INF/classes/Echo.class
<servlet>
        <servlet-name>......</servlet-name>
        <servlet-class>.....</servlet-class>
</servlet>
<servlet-mapping>
        <servlet-name>......</servlet-name>
        <url-pattern>.......</url-pattern >
</servlet-mapping>
- HTML:
<FORM method=“post” action=“/servlet/Test”>
- Server (webapps):
WEB-INF/classes/foo/Name.class
<servlet>
        <servlet-name>......</servlet-name>
        <servlet-class>.....</servlet-class>
</servlet>
<servlet-mapping>
        <servlet-name>......</servlet-name>
        <url-pattern>.......</url-pattern >
</servlet-mapping>

3. Example: A Small Form

//SmallForm.html
<html>
    <title>Sending Form Information to a Servlet</title>
    <body>
        <form action="http://localhost:8080/servlet/elem004.ProcessSmallForm"method="post">
            //Can use absolute or relative URLs or pre-configured names.
            Please input your login: <br>
            <input type="text" name="Login">
            <input type="submit" value="Login">
        </form>
    </body>
</html>

//the Deployment Descriptor (web.xml) and the servlet
<servlet>
     <servlet-name>smallForm</servlet-name>
     <servlet-class>SmallFormServlet</servlet-class>
</servlet>
<servlet-mapping>
     <servlet-name>smallForm</servlet-name>
     <url-pattern>/servlet/elem004.ProcessSmallForm</url-pattern>
</servlet-mapping>

4. Putting everything in the right place

Level 1WEB-INF (folder) and .html, .jsp
Level 2(inside WEB-INF folder): web.xml and classes (folder)
Level 3 (inside classes folder): servlet .class files (and other “business” class files e.g. JavaBeans)

5. Servlet initialisation & Servlet Configuration object

• Only one servlet instance is created: each request is serviced by a separate thread in the container.
• Prior to initialisation, the ServletConfig object is created by the container:
– one ServletConfig object per servlet;
– container uses it to pass deploy-time information to the servlet (data you do not want to hard code into the servlet, e.g. the DB name);
– the names are specified in the DD.
• Parameters are set in a server-specific manner, e.g.
– in a file called web.xml (for Tomcat);
– in a file called resin.config (for Resin).
• Parameters do not change while servlet is deployed and running:
– like constants;
– if servlet changes, then need to redeploy.

6. Example: DD’s init parameters (web.xml for Tomcat)

<web-app xmlns=“http://java.sun.com/xml/ns/j2ee”
     xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
     xsi:schemaLocation=“http//java.sun.com/xml/ns/j2ee/web-app_2.4.xsd”
     version=“2.4”>
    <servlet>
        <servlet-name>Hello World Servlet</servlet-name>
        <servlet-class>S1</servlet-class>
        <init-param>
            <param-name>lecturersEmail</param-name>
            <param-value>paula.fonseca@qmul.ac.uk</param-value>
        </init-param>
        //Container reads these & gives them to ServletConfig object.
    </servlet>
</web-app>
out.println(getServletConfig().getInitParameter(“lecturersEmail”));
Returns the servlet’s ServletConfig object (all servlets have this method).
Getting a parameter value from the ServletConfig object; this code is in servlet.

7. Creating a servlet: ServletConfig and init(…)

Step 1container reads the deployment descriptor
Step 2container creates new ServletConfig object
Step 3
container creates name/value pair (Strings) for each servlet init-param
Step 4
container passes references to these to the ServletConfig object
Step 5container creates new instance of the servlet class
Step 6
container calls servlet’s init() method passing in reference to the ServletConfig object

六、Thread Safety And Putting Things Together

1. Instance Variables

public class ExampletServlet extends HttpServlet {
private int age;
public void init() { age = 0; }
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws
IOException, ServletException {
age = Integer.parseInt(request.getParameter(“age”));
response.setContentType(“text/html”);
PrintWriter out = response.getWriter();
out.println(“<HTML><BODY>You are ” + age + “ weeks old”);
out.println(“</BODY></HTML>”);
out.close();
}
}

2. The 3 Threads access same Resources

• We don’t know whose age will be displayed!
• Solution 1:
– Never use instance variables in servlets (some books say you
can’t – what they mean is you shouldn’t!).
– Find a way to save information (state) about each user (i.e.
each request) – we’ll see how later …
• Solution 2:
Synchronisation – a lock that makes a variable thread-safe

3. Access – introducing the ServletContext object

Servlet
ServletConfig object – one per servlet (or JSP)
– contains init params
– all requests made to a servlet can access this object
• Web application
ServletContext object – one per web application
• Web applications normally have several servlets/JSPs.
– Used to access web application parameters that need to be seen by all servlets/JSPs in the application.
• A misnomer, as it relates not to a servlet but to the set of servlets and JSPs in the web application.
The web application’s DD specifies the context parameters

<web-app ...> ...
    <servlet>
        <servlet-name>...</servlet-name>
        <servlet-class>...</servlet-class>
    <init-param>
        <param-name>...</param-name>
        <param-value>...</param-value></init-param>
    </servlet> ... + other servlets
    <context-param>
        <param-name>HOP_Email</param-name>
        <param-value>g.tyson@qmul.ac.uk</param-value>
    </context-param>
...
</web-app>

Note: Not inside any servlet. These are parameter namevalue pairs: both are strings.

ServletContext object created and set up when web application is deployed.

4. To access web app parameters in servlet code

ServletContext ctx = getServletContext();
out.println(ctx.getInitParameter(“HOP_Email”));
Context parameters generally more commonly used than Config.
– Typical use (of former) is a DB lookup name.
• Can access ServletContext,
– directly: getServletContext().getInitParameter(…)
– from ServletConfig: getServletConfig().getServletContext().getInitParameter(…)
– Latter is useful if in a method of an auxiliary class e.g. a JavaBean, and only the ServletConfig object has been passed as a parameter.
Same name for get method as when accessing ServletConfig object.

5. ServletContext also has attributes

• Parameters are name-value pairs, where both name and value are strings.
• Attributes are name-value pairs where the name is a String, but the value is an object (that may not be a String).
– accessed by getAttribute(String);
– set by setAttribute(String,Object).
• Running code prior to invoking any servlet in the application:
– E.g. to turn sets of parameters into attribute objects,
• so all servlets only need to deal with objects;
• and don’t have to read the context parameters.
– Implement a ServletContextListener (out of scope here)

6. Servlets – The Basics: Key Points & What we can’t do yet

How to call a servlet in an HTML formWhat a deployment descriptor does
How to write a servletWhere to deploy files
How to access client informationServlet life-cycle
Initialisation
ServletConfig
ServletContext
Have a conversation with a client
– Shopping basket
Session object
Run any code before a servlet starts
– E.g. Database set up
Listeners

Send client information, or control,

to another servlet/JSP

– Could be in another web server
Redirect and forward

7. Extracting unknown parameters and multiple values

String getParameter(String)
parameter name is known:
– returns null if unknown parameter;
– returns "" (i.e. empty string) if parameter has no value.
Enumeration getParameterNames() obtain parameter names
String[] getParameterValues(String) 

obtain an array of values for each one:

– returns null if unknown parameter;
– returns a single string ("") if parameter has no values. Case sensitive.

8. Example: A Big Form

//BigForm.html
<form action="http://localhost:8080/servlet/elem004.ProcessBigForm"method="post">
    Please enter: <br><br>
    Your login: <input type="text" name="Login"> <br><br>
    Your favourite colour:
    <input type="radio" name="Colour" value="blue">Blue
    <input type="radio" name="Colour" value="red">Red
    <input type="radio" name="Colour" value="green">Green <br><br>
    //Single-value parameters.
    Which of these courses you are taking: <br>
    <input type="checkbox" name="Course" value="elem001">ELEM001 <br>
    <input type="checkbox" name="Course" value="elem002">ELEM002 <br>
    <input type="checkbox" name="Course" value="elem003">ELEM003 <br>
    <input type="checkbox" name="Course" value="elem004">ELEM004 <br>
    <input type="submit" value="Send to Servlet">
    //Multiple-value parameter.
</form>
//After BigForm is processed.getParameterNames() returns parameters in no particular order.

//ProcessBigForm.java
//More code here ...
    out.println("<table border=1>");
    // Obtain all the form’s parameters from the request object.
    Enumeration paramNames = req.getParameterNames();
    while (paramNames.hasMoreElements()) {
        String paramName = (String) paramNames.nextElement();
        // Obtain values for this parameter and check how many there are.
        String[] paramValues = req.getParameterValues(paramName);
        if (paramValues.length == 1) { // a single value
            String paramVal = req.getParameter(paramName);
            out.println("<tr><td>" + paramName +"</td><td>"+ paramVal + "</td></tr>");
        }else { // If several values print a list in the table.
            out.println("<tr><td>" + paramName +"</td><td><ul>");
            for (int i = 0; i < paramValues.length; i++)
                out.println("<li>" + paramValues[i] + "</li>");
                out.println("</ul></td></tr>");
        }
    }
    out.println("</table>");
    out.close();
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1256410.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Rust的异步编程与Futures

欢迎关注我的公众号lincyang新自媒体&#xff0c;回复关键字【程序员经典书单】&#xff0c;领取程序员的100本经典书单 大家好&#xff01;我是lincyang。 今天&#xff0c;我们来探讨Rust中的异步编程和Futures。Rust的异步编程是一个强大的特性&#xff0c;它允许开发者编写…

FloodFill

"绝境之中才窥见&#xff0c;Winner&#xff0c;Winner" FloodFill算法简介: floodfill又翻译成漫水填充。我们可以将下面的矩阵理解为一片具有一定高度的坡地&#xff0c;此时突发洪水&#xff0c;洪水会将高度<0的地方填满。 话句话来说&#xff0c;Fl…

NX二次开发UF_CURVE_ask_trim 函数介绍

文章作者&#xff1a;里海 来源网站&#xff1a;https://blog.csdn.net/WangPaiFeiXingYuan UF_CURVE_ask_trim Defined in: uf_curve.h int UF_CURVE_ask_trim(tag_t trim_feature, UF_CURVE_trim_p_t trim_info ) overview 概述 Retrieve the current parameters of an a…

Java + openCV更换证件照背景色

最近在小红书上看到很多更换证件照背景色的需求&#xff0c;联想到以前自己也更换过证件照背景色而且还是付费的&#xff0c;碰巧最近在看一本书《JavaOpenCV高效入门》&#xff0c;于是查找资料&#xff0c;找到了通过技术解决这个需求的办法。 先看效果图&#xff08;图片来自…

OpenCV入门11——图像的分割与修复

文章目录 图像分割的基本概念实战-分水岭法(一)实战-分水岭法(二)GrabCut基本原理实战-GrabCut主体程序的实现实战-GrabCut鼠标事件的处理实战-调用GrabCut实现图像分割meanshift图像分割视频前后景分离其它对视频前后影分离的方法图像修复 图像分割是计算机视觉中的一个重要领…

window环境搭建StarRocksFE节点

StarRocks部署–源码编译 前言 ​ 注意:本文借用了一些其他文章的一些截图&#xff0c;同时自己做了具体的编译步骤&#xff0c;添加了一些新的内容 ​ 目标&#xff1a; 编译StarRocks2.5.13版本FE节点代码&#xff0c;在本地window环境运行&#xff0c;可以访问到8030界面…

频剪辑软件Corel VideoStudio 会声会影2024最新7大新全新功能解析

我很喜欢视频剪辑软件Corel VideoStudio 会声会影2024&#xff0c;因为它使用起来很有趣。它很容易使用&#xff0c;但仍然给你很多功能和力量。视频剪辑软件Corel VideoStudio 会声会影2023让我与世界分享我的想法&#xff01;“这个产品的功能非常多&#xff0c;我几乎没有触…

【数据中台】开源项目(2)-Wormhole流式处理平台

Wormhole 是一个一站式流式处理云平台解决方案&#xff08;SPaaS - Stream Processing as a Service&#xff09;。 Wormhole 面向大数据流式处理项目的开发管理运维人员&#xff0c;致力于提供统一抽象的概念体系&#xff0c;直观可视化的操作界面&#xff0c;简单流畅的配置管…

《已解决: ImportError: Keras requires TensorFlow 2.2 or higher 问题》

&#x1f337;&#x1f341; 博主猫头虎&#xff08;&#x1f405;&#x1f43e;&#xff09;带您 Go to New World✨&#x1f341; &#x1f984; 博客首页: &#x1f405;&#x1f43e;猫头虎的博客&#x1f390;《面试题大全专栏》 &#x1f995; 文章图文并茂&#x1f996…

vscode 使用git提交前端代码

1、项目初始化git 如果是从其他地方拉的代码&#xff0c;把.git文件删除&#xff0c;再重新初始化。 2、提交代码 2.1、提交本地库 2.2、提交远程仓库 2.2.1、创建远程仓库 2.2.2、提交远程仓库–master分支 在本地添加远程仓库&#xff0c;设置别名为origin git remote…

首届教师案例教学竞赛一等奖作品上线至和鲸社区,快来学习!

细心的朋友可能已经发现&#xff0c;近期和鲸社区的频道页上线了一个新专区——“优秀参赛作品专区”。 图.和鲸社区频道页 迄今为止&#xff0c;和鲸参与/支持了 500 多场专业数据科学竞赛&#xff0c;包括面向气象、金融、医学、海洋等不同领域的&#xff0c;面向从业者、科学…

为你的项目加上微信登录(个人开发)

当我们开发个人项目的时候&#xff0c;为了用户登录的便捷性&#xff0c;经常会给我们的项目加上一些除了注册之外的方式&#xff0c;其中最常见的就是微信登录&#xff0c;但作为个人开发者&#xff0c;是无法使用微信的授权登录的&#xff0c;但是通过微信公众号可以获得同样…

【nginx】 实现限流

这里写自定义目录标题 前言正文nginx实现限流并发限制限制单IP并发数量限制单主机服务并发数量 速率限制限流效果 注意疑问参考链接 小结 前言 好久不见&#xff0c;还算为时不晚。最近一个月经历了工作的调整&#xff0c;技术栈从Java转向了Go和Python, 工作显得更忙了些&…

JavaScript基础—for语句、循环嵌套、数组、冒泡排序、综合案例—根据数据生成柱形图

版本说明 当前版本号[20231126]。 版本修改说明20231126初版 目录 文章目录 版本说明目录JavaScript 基础第三天笔记for 语句for语句的基本使用循环嵌套倒三角九九乘法表 数组数组是什么&#xff1f;数组的基本使用定义数组和数组单元访问数组和数组索引数据单元值类型数组长…

测试工程师必学看系列之Jmeter_性能测试:性能测试的流程和术语

性能测试的流程 一、准备工作 1、系统基础功能验证 一般情况下&#xff0c;只有在系统基础功能测试验证完成、系统趋于稳定的情况下&#xff0c;才会进行性能测试&#xff0c;否则性能测试是无意义的。2、测试团队组建 根据该项目的具体情况&#xff0c;组建一个几人的性能测试…

Linux面试题(三)

目录 34、du 和 df 的定义&#xff0c;以及区别&#xff1f; 35、awk 详解。 36、当你需要给命令绑定一个宏或者按键的时候&#xff0c;应该怎么做呢&#xff1f; 37、如果一个 linux 新手想要知道当前系统支持的所有命令的列表&#xff0c;他需要怎么做&#xff1f; 38、…

23年几个能打的UE4游戏技术选型

近期发现很多的精力放在游戏的整体技术选型以及产生的结果上面&#xff0c;所以回顾下几个游戏的选型和结果&#xff1b; 这里一个是自己玩游戏的画面流畅度的直接感受&#xff0c;以及一直非常喜爱的评测“数毛社”&#xff0c;digital foundry&#xff1b; 23年目前来看&…

【NeRF】3、MobileR2L | 移动端实时的神经光场(CVPR2023)

论文&#xff1a;Real-Time Neural Light Field on Mobile Devices 代码&#xff1a;https://github.com/snap-research/MobileR2L 出处&#xff1a;CVPR2023 贡献&#xff1a; 设计了一套移动端实时的 R2L 网络结构 MobileR2L&#xff0c;在 iphone13 上渲染一张 1008x756…

前端学习--React(4)路由

一、认识ReactRouter 一个路径path对应一个组件component&#xff0c;当我们在浏览器中访问一个path&#xff0c;对应的组件会在页面进行渲染 创建路由项目 // 创建项目 npx create router-demo// 安装路由依赖包 npm i react-router-dom// 启动项目 npm run start 简单的路…

【JavaEE】多线程 (2) --线程安全

目录 1. 观察线程不安全 2. 线程安全的概念 3. 线程不安全的原因 4. 解决之前的线程不安全问题 5. synchronized 关键字 - 监视器锁 monitor lock 5.1 synchronized 的特性 5.2 synchronized 使⽤⽰例 1. 观察线程不安全 package thread; public class ThreadDemo19 {p…