JSP註冊登錄頁教程

来源:http://www.cnblogs.com/zhangyukof/archive/2017/05/08/6785258.html
-Advertisement-
Play Games

轉載請標明原文地址:http://www.cnblogs.com/zhangyukof/p/6785258.html 一、準備工作 已搭建好的SSH框架工程一個,如果沒有,請參考我的上一篇文章《SSH框架搭建詳細圖文教程》。 二、登陸功能 1.打開MyEclipse切換到MyEclipse Data ...


 

轉載請標明原文地址:http://www.cnblogs.com/zhangyukof/p/6785258.html 

一、準備工作

已搭建好的SSH框架工程一個,如果沒有,請參考我的上一篇文章《SSH框架搭建詳細圖文教程》。

 

二、登陸功能

1.打開MyEclipse切換到MyEclipse DataBase Explorer視圖,右鍵user表選擇"Hibernate Reverse Engineering",通過Spring框架的逆向工程功能把user表逆向生成Java實體類。

 

 

2.在彈出視窗中Java src folder 選擇SSH項目下的src文件夾。Java package 填寫“com.ssh.spring.user”。

勾選前三個選項:Create POJO、Java Data Obect和Java Data Access Object。POJO類是資料庫表格所對應的Java類,JDO類是MyEclipse自動生成的對資料庫的一些操作,這裡會封裝一些常用的操作,基本上可以滿足我們的各種需要了,填寫後選擇“下一步”。

 

3.Id Generator 選擇“native”,點擊完成。

 

4.此時的目錄結構如下,我們可以看到系統生成了3個類,一個配置文件。
User 繼承自AbstractUser,是User表的實體類。
UserDAO 封裝了一些對資料庫的常用操作。
User.hbm.xml 是hibernate-mapping映射配置文件,配置了哪個實體類映射哪個表,配置了實體類的哪個屬性映射表裡的哪列。

 

5.現在來寫測試頁。打開WEB-INF文件夾下的struts-config.xml文件,切換到設計視圖(design)。在空白處右鍵 > New > Form Action and JSP。

 

6.填寫Form表單屬性:
Use case: login
在下方Form Properties中點擊“Add”添加兩個屬性
username: JSP input type選擇“text”
password: JSP input type選擇“password”

 

7.切換到JSP選項,勾選“Create JSP form”選項讓系統自動生成login.jsp頁,點擊“完成”。

 

8.完成後項目結構如下,Struts幫我們建立了邏輯關係並生成了login.jsp、LoginForm.java、LoginAction.java三個文件。這正是我們在設計視圖裡選擇Form,Action and JSP所配置的信息。

 

9.把struts-config.xml切換到source源代碼視圖,可以看到struts的配置文件里也相應的添加了這3個文件的映射配置信息。

 

Struts處理請求的流程:

 

10.新建一個loginSuccess.jsp登陸成功頁,實現登陸後的跳轉。右鍵項目的WebRoot/form文件夾 選擇“新建” > “JSP(Advanced Templates)”。

 

11.在彈出視窗中“File Name”處填寫:loginSuccess.jsp。

 

12.打開loginSuccess.jsp修改頁面代碼如下:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>登陸成功頁</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->

  </head>
  
  <body>
  <% Object nickname = request.getAttribute("nickname"); %>
    登陸成功!歡迎您:<% out.print(nickname); %><br>
  </body>
</html>

 

 

13.把登錄頁、登錄成功跳轉、登錄失敗跳轉關聯到一起。
切換到struts-config.xml的設計視圖。在視圖中右鍵選擇 New->Forward。

 

 

14.在彈出視窗中配置如下信息:
(1)選擇Local Action Forward
(2)瀏覽Action Path:/login
(3)填寫name:loginSuccess
(4)瀏覽Path:/form/loginSuccess.jsp
(5)點擊“完成”

 

15.添加一個登陸失敗跳轉。在設計視圖中的右鍵選擇 New->Forward。在彈出視窗中配置如下信息:
(1)選擇Local Action Forward
(2)瀏覽Action Path:/login
(3)填寫name:loginFail
(4)瀏覽Path:/form/login.jsp
(5)點擊“完成”

添加跳轉後struts-config.xml結構如下:

 

16.切換到struts-config.xml的source視圖,可以看到在aciton下多了兩行跳轉信息。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
  <data-sources />
  <form-beans >
    <form-bean name="loginForm" type="com.ssh.struts.form.LoginForm" />

  </form-beans>

  <global-exceptions />
  <global-forwards />
  <action-mappings >
    <action
      attribute="loginForm"
      input="/form/login.jsp"
      name="loginForm"
      path="/login"
      scope="request"
      type="com.ssh.struts.action.LoginAction">
      <set-property property="cancellable" value="true" />
      <forward name="loginSuccess" path="/form/loginSuccess.jsp" />
      <forward name="loginFail" path="/form/login.jsp" />
    </action>

  </action-mappings>

  <message-resources parameter="com.ssh.struts.ApplicationResources" />
</struts-config>

 

17.寫具體的處理代碼。打開struts/aciton包下的LoginAction.java。修改代碼如下,先不連資料庫測一下是否能夠正確跳轉。

package com.ssh.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.ssh.struts.form.LoginForm;

public class LoginAction extends Action {

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
        
        LoginForm loginForm = (LoginForm) form;
        //獲取帳號密碼
        String username = loginForm.getUsername();
        String password = loginForm.getPassword();
        //帳號密碼匹配跳轉到登錄成功頁並顯示昵稱
        if("asd".equals(username) && "123".equals(password)){
            request.setAttribute("nickname", "冰封百度");
            return mapping.findForward("loginSuccess");
        }
        //不匹配,跳轉到登錄失敗頁並顯示提示信息
        request.setAttribute("message", "賬號或密碼錯誤");
        return mapping.findForward("loginFail");
    }
}

 

18.頁面準備完畢。啟動Tomcat伺服器,在瀏覽器中訪問登陸頁地址:http://127.0.0.1:8080/SSH/form/login.jsp

 

19.漢化界面。打開login.jsp,代碼如下:

<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%> 
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
 
<html> 
    <head>
        <title>JSP for LoginForm form</title>
    </head>
    <body>
        <html:form action="/login">
            username : <html:text property="username"/><html:errors property="username"/><br/>
            password : <html:password property="password"/><html:errors property="password"/><br/>
            <html:submit/><html:cancel/>
        </html:form>
    </body>
</html>

註意:頭部引用的文件位置是"http://struts.apache.org/",路徑地址是國外apache的官網文件,這個地址經常會訪問不到,導致頁面打開失敗,所以這裡要改成自己工程下的文件路徑。

頁面代碼修改如下:

<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
 
<html> 
    <head>
        <title>登陸頁</title>
    </head>
    <body>
        <html:form action="/login">
            用戶名 : <html:text property="username"/><html:errors property="username"/><br/>
            密 碼 : <html:password property="password"/><html:errors property="password"/><br/>
            <html:submit value="登陸" /><html:cancel value="取消"/>
        </html:form>
        <% Object message = request.getAttribute("message"); %>
        <% if(message != null) out.print(message); %>
    </body>
</html>

 

刷新頁面可以看到如下效果:

 

20.直接點擊登陸。因為沒填賬號密碼,應該跳轉到登陸失敗頁面。

 

21.用戶名填寫“asd”,密碼填寫“123”。點擊登錄,帳號密碼和後臺設置的匹配,這時候應該跳轉到登錄成功頁面。

 

22.測試完成,下麵我們連接一下資料庫,從資料庫里取出user數據進行匹配。
想操作資料庫我們要先獲取DAO(data access object),我們的UserDAO是hibernate生成的,關於UserDAO的配置信息寫在了applicationContext.xml里。所以在用UserDAO之前要先獲取
applicationContext.xml

百度上查找了一下相關代碼,找到了一個獲取applicationContext.xml的方法。Spring框架里的
ClassPathXmlApplicationContext 通過這個類可以獲取到我們需要的DAO。名字和applicationContext非常像,看起來就是這個類了,測試一下這個類是否好用,修改LoginAction.java代碼如下:

package com.ssh.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.ssh.struts.form.LoginForm;

public class LoginAction extends Action {

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
        
        LoginForm loginForm = (LoginForm) form;
        //獲取帳號密碼
        String username = loginForm.getUsername();
        String password = loginForm.getPassword();
        //獲取用戶信息
        ClassPathXmlApplicationContext beans = new ClassPathXmlApplicationContext("applicationContext.xml");
        System.out.println(beans);
        //帳號密碼匹配跳轉到登錄成功頁並顯示昵稱
        if("asd".equals(username) && "123".equals(password)){
            request.setAttribute("nickname", "冰封百度");
            return mapping.findForward("loginSuccess");
        }
        //不匹配,跳轉到登錄失敗頁並顯示提示信息
        request.setAttribute("message", "賬號或密碼錯誤");
        return mapping.findForward("loginFail");
    }
}

 

23.重啟Tomcat伺服器,訪問登錄頁http://127.0.0.1:8080/SSH/form/login.jsp,點擊登錄。

javax.servlet.ServletException: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]

出現了一個錯誤,意思為找不到applicationContext.xml。看來我們填寫的路徑有問題,這個配置文件應該是從我們項目classes的根目錄開始查找的,先看一下我們的項目發佈後classes的路徑,右鍵SSH項目 > 屬性 > Java構建路徑 > 源代碼。

可以看到我們項目發佈後classes的根目錄是SSH/WebRoot/WEB-INF/classes。 applicationContext.xml是這個位置的上一級,那麼相對於這個路徑的位置就是"../applicationContext.xml"。現在把LoginAction里的路徑修改一下:

ClassPathXmlApplicationContext beans = new ClassPathXmlApplicationContext("../applicationContext.xml");

重新啟動Tomcat伺服器,訪問登錄頁http://127.0.0.1:8080/SSH/form/login.jsp,點擊登錄:
頁面不再報錯,正常跳轉,控制台也輸出了:
org.springframework.context.support.ClassPathXmlApplicationContext@14bb075: startup date [Mon Apr 22 14:26:58 CST 2017]; root of context hierarchy]

如果頁面還是出錯,出現以下信息,則有可能Java EE庫的版本低了,請刪除項目里的Java EE庫重新添加Java EE 6.0庫

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [config/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration

 

24.路徑的問題解決了,正確的獲取到了配置信息,這個配置信息我們以後要經常用,沒必要每次用的時候都把它創建出來,寫一個全局變數保存它吧。在src下新建一個包com.ssh.common,在包里新建一個類Global.java。輸入代碼如下:

package com.ssh.common;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Global {
    
    public static ClassPathXmlApplicationContext beans = new ClassPathXmlApplicationContext("../applicationContext.xml");
    
    public static Object getDao(String daoName){
        return beans.getBean(daoName);
    }
}

 

26.現在來獲取資料庫里的數據,上一篇文章中建的user表中已經插入了一條數據,就用這個用戶信息來測試。

把LoginAction.java代碼修改如下:

package com.ssh.struts.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.ssh.common.Global;
import com.ssh.spring.user.User;
import com.ssh.spring.user.UserDAO;
import com.ssh.struts.form.LoginForm;

public class LoginAction extends Action {

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
        
        LoginForm loginForm = (LoginForm) form;
        //獲取帳號密碼
        String username = loginForm.getUsername();
        String password = loginForm.getPassword();
        //檢查該用戶是否存在
        User instance = new User();
        instance.setUsername(username);
        instance.setPassword(password);
        UserDAO userDAO = (UserDAO)Global.getDao("UserDAO");
        List<?> list = userDAO.findByExample(instance);
        //如果用戶存在,跳轉到登錄成功頁並顯示昵稱
        if(list.size() > 0){
            User user = (User)list.get(0);
            String nickname = user.getNickname();
            request.setAttribute("nickname", nickname);
            return mapping.findForward("loginSuccess");
        }
        //用戶不存在,跳轉到登錄失敗頁並顯示提示信息
        request.setAttribute("message", "賬號或密碼錯誤");
        return mapping.findForward("loginFail");
    }
}

重新啟動Tomcat伺服器,訪問登錄頁http://127.0.0.1:8080/SSH/form/login.jsp,用戶名:admin,密碼:1234,點擊登錄。可以看到,跳轉到登陸成功頁並顯示了正確的昵稱。

登錄功能完成,因為只是個測試頁,這些功能就儘量簡單了,大家別介意,下麵來做註冊功能。

 

三、註冊功能

1.切換到struts-config.xml的設計視圖,空白處右鍵選擇 New > Form,Action and JSP。

 

2.在彈出視窗中配置如下信息:

Use case填寫“register”
Form Properties點擊“Add”添加三個屬性
(1)username    type:text
(2)password    type:password
(3)nickname    type:text

 

3.點擊JSP選項,勾選Create JSP form,點擊“完成”。

 

4.關聯測試頁和登陸頁。右鍵struts-config.xml設計視圖中的regiser.jsp 選擇  New > Forward。

 

5.添加註冊成功跳轉。在彈出視窗中配置如下信息:

(1)選擇Local Action Forward
(2)Action Path:/register
(3)Name:registerSuccess
(4)Path:/form/login.jsp

點擊“完成”。

 

6.添加註冊失敗跳轉。右鍵struts-config.xml設計視圖中的regiser.jsp 選擇  New > Forward。在彈出視窗中配置如下信息:

(1)選擇Local Action Forward
(2)Action Path:/register
(3)Name:registerFail
(4)Path:/form/register.jsp

點擊“完成”。

關聯成功後struts-config.xml代碼如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
  <data-sources />
  <form-beans >
    <form-bean name="loginForm" type="com.ssh.struts.form.LoginForm" />
    <form-bean name="registerForm" type="com.ssh.struts.form.RegisterForm" />

  </form-beans>

  <global-exceptions />
  <global-forwards />
  <action-mappings >
    <action
      attribute="loginForm"
      input="/form/login.jsp"
      name="loginForm"
      path="/login"
      scope="request"
      type="com.ssh.struts.action.LoginAction">
      <set-property property="cancellable" value="true" />
      <forward name="loginSuccess" path="/form/loginSuccess.jsp" />
      <forward name="loginFail" path="/form/login.jsp" />
    </action>
    <action
      attribute="registerForm"
      input="/form/register.jsp"
      name="registerForm"
      path="/register"
      scope="request"
      type="com.ssh.struts.action.RegisterAction">
      <set-property property="cancellable" value="true" />
      <forward name="registerSuccess" path="/form/login.jsp" />
      <forward name="registerFail" path="/form/register.jsp" />
    </action>

  </action-mappings>

  <message-resources parameter="com.ssh.struts.ApplicationResources" />
</struts-config>

 

7.漢化註冊頁。register.jsp修改後代碼如下:

<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
 
<html> 
    <head>
        <title>註冊頁</title>
    </head>
    <body>
        <html:form action="/register">
            昵 稱 : <html:text property="nickname"/><html:errors property="nickname"/><br/>
            用戶名 : <html:text property="username"/><html:errors property="username"/><br/>
            密 碼 : <html:password property="password"/><html:errors property="password"/><br/>
            <html:submit value="確定"/><html:cancel value="取消"/>
        </html:form>
        <% Object message = request.getAttribute("message"); %>
        <% if(message != null) out.print(message); %>
    </body>
</html>

 

8.把註冊信息插入資料庫。打開RegisterAction.java文件,修改代碼如下:

package com.ssh.struts.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.ssh.common.Global;
import com.ssh.spring.user.User;
import com.ssh.spring.user.UserDAO;
import com.ssh.struts.form.RegisterForm;

public class RegisterAction extends Action {
    
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
        
        //獲取註冊信息
        RegisterForm registerForm = (RegisterForm) form;
        String nickname = registerForm.getNickname();
        String username = registerForm.getUsername();
        String password = registerForm.getPassword();
       
        //檢查表單值是否有效
        if(nickname.length() == 0 || username.length() == 0 || password.length() == 0){
            request.setAttribute(

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 最近做了一個使用 C# 寫了一個發送郵件的 windows 服務,在這裡記錄一下。 首先使用 Visual Studio 2015 創建一個 windows 服務項目。 然後在設計器上面右擊添加安裝程式。如下圖。 安裝好後,選擇安裝程式設計界面,選擇服務和安裝程式右擊選擇屬性修改一些屬性值。 PS: ...
  • 文檔目錄 本節內容: 簡介 IObjectMapper 介面 集成 AutoMapper 安裝 創建映射 自動映射的特性 自定義映射 擴展方法 MapTo 單元測試 預定義的映射 LocalizableString -> string 註入 IMapper 安裝 創建映射 自動映射的特性 自定義映射 ...
  • 《Effective C#》快速筆記 - C# 高效編程要點補充 目錄 四十五、儘量減少裝箱拆箱 四十六、為應用程式創建專門的異常類 四十七、使用強異常安全保證 四十八、儘量使用安全的代碼 四十九、實現與 CLS 相容的程式集 五十、實現小尺寸、高內聚的程式集 這是這一系列的最後一篇。 四十五、儘量 ...
  • .NET數據訪問 在.NET中對於數據的訪問大致有三個層面,數據訪問層、記憶體數據集、業務邏輯層。數據層,包括了XML配置文件以及一些常用的資料庫(使用SQL語句);記憶體數據集,主要是DataSet數據集,在DataSet中包括Datatable,而Datatable中又分為DataRow和DataC ...
  • 首先要準備一下的工具作為環境 MySQL Community Server 5.7.x My Workbench 6.3 VS2017 新建一個項目,NetMySQLCodeFirst 選擇MVC,再選擇無用戶驗證 然後通過NuGet包管理器安裝三個包,安裝最新穩定版本即可 EntityFramew ...
  • MVC中這樣實現。。。 ...
  • 前言: 該博客產生的背景是客戶那邊有部署網站的方法是iis authentication身份驗證,而系統中使用Webclient來調用別的系統的方法。在此情況下,原本可以使用的功能,都不能調用方法了,返回結果是401。在經過艱難地查找資料之後,也沒有找到很好的方法來解決。找到的幾個方法也不能很好的解 ...
  • 02 線性結構2:一元多項式的乘法與加法運算 Description: 設計函數分別求兩個一元多項式的乘積與和。 Input: 輸入分2行,每行分別先給出多項式非零項的個數,再以指數遞降方式輸入一個多項式非零項繫數和指數(絕對值均為不超過1000的整數)。數字間以空格分隔。 Output: 輸出分2 ...
一周排行
    -Advertisement-
    Play Games
  • 前言 本文介紹一款使用 C# 與 WPF 開發的音頻播放器,其界面簡潔大方,操作體驗流暢。該播放器支持多種音頻格式(如 MP4、WMA、OGG、FLAC 等),並具備標記、實時歌詞顯示等功能。 另外,還支持換膚及多語言(中英文)切換。核心音頻處理採用 FFmpeg 組件,獲得了廣泛認可,目前 Git ...
  • OAuth2.0授權驗證-gitee授權碼模式 本文主要介紹如何筆者自己是如何使用gitee提供的OAuth2.0協議完成授權驗證並登錄到自己的系統,完整模式如圖 1、創建應用 打開gitee個人中心->第三方應用->創建應用 創建應用後在我的應用界面,查看已創建應用的Client ID和Clien ...
  • 解決了這個問題:《winForm下,fastReport.net 從.net framework 升級到.net5遇到的錯誤“Operation is not supported on this platform.”》 本文內容轉載自:https://www.fcnsoft.com/Home/Sho ...
  • 國內文章 WPF 從裸 Win 32 的 WM_Pointer 消息獲取觸摸點繪製筆跡 https://www.cnblogs.com/lindexi/p/18390983 本文將告訴大家如何在 WPF 裡面,接收裸 Win 32 的 WM_Pointer 消息,從消息裡面獲取觸摸點信息,使用觸摸點 ...
  • 前言 給大家推薦一個專為新零售快消行業打造了一套高效的進銷存管理系統。 系統不僅具備強大的庫存管理功能,還集成了高性能的輕量級 POS 解決方案,確保頁面載入速度極快,提供良好的用戶體驗。 項目介紹 Dorisoy.POS 是一款基於 .NET 7 和 Angular 4 開發的新零售快消進銷存管理 ...
  • ABP CLI常用的代碼分享 一、確保環境配置正確 安裝.NET CLI: ABP CLI是基於.NET Core或.NET 5/6/7等更高版本構建的,因此首先需要在你的開發環境中安裝.NET CLI。這可以通過訪問Microsoft官網下載並安裝相應版本的.NET SDK來實現。 安裝ABP ...
  • 問題 問題是這樣的:第三方的webapi,需要先調用登陸介面獲取Cookie,訪問其它介面時攜帶Cookie信息。 但使用HttpClient類調用登陸介面,返回的Headers中沒有找到Cookie信息。 分析 首先,使用Postman測試該登陸介面,正常返回Cookie信息,說明是HttpCli ...
  • 國內文章 關於.NET在中國為什麼工資低的分析 https://www.cnblogs.com/thinkingmore/p/18406244 .NET在中國開發者的薪資偏低,主要因市場需求、技術棧選擇和企業文化等因素所致。歷史上,.NET曾因微軟的閉源策略發展受限,儘管後來推出了跨平臺的.NET ...
  • 在WPF開發應用中,動畫不僅可以引起用戶的註意與興趣,而且還使軟體更加便於使用。前面幾篇文章講解了畫筆(Brush),形狀(Shape),幾何圖形(Geometry),變換(Transform)等相關內容,今天繼續講解動畫相關內容和知識點,僅供學習分享使用,如有不足之處,還請指正。 ...
  • 什麼是委托? 委托可以說是把一個方法代入另一個方法執行,相當於指向函數的指針;事件就相當於保存委托的數組; 1.實例化委托的方式: 方式1:通過new創建實例: public delegate void ShowDelegate(); 或者 public delegate string ShowDe ...