java web 來源頁_Java:Java Web--分頁效果

先來看一看分頁的實現原理

b3717ff907e2

萬能公式.jpg

b3717ff907e2

項目目錄.PNG

首先,新建Java Web項目

一. 梳理業務邏輯

重定向到URL(跳轉到StudentViewAction頁面)//index.jsp頁面

1.從頁面接收可變的值

2.接收值有問題時,初始化為1

3.如果沒有問題,把String類型接收值強轉成Integer

4.實例DAO方法,調用findStudentListByPageCount()方法(該方法得到總條數)

5.計算總頁數:總頁數 = 總條數 % 頁容量

6.判斷接收到頁面傳來的值是否小于1頁

7.調用DAO中findStudentListByPageCount()(該方法獲取數據集合)

8.封裝打包頁面

9.轉發頁面

request.getRequestDispatcher("list.jsp").forward(request, response);

//request.getRequestDispatcher("list.jsp") 找到要轉發的頁面

//forward(request, response); 實現轉發

二. 實現界面展示

1.封裝工具類JDBCUtil.java文件, 作用是連接數據庫

package com.fyl.util;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.util.Scanner;

/**

* 文檔注釋(Java連接數據庫的工具類)

*

*/

public class JDBCUtil {

// 注意:四個屬性:驅動, 地址(URL), 用戶名, 密碼

// 驅動類:通過一個類名告訴java我現在使用的是什么數據庫

private static final String CONN_DRIVER = "com.mysql.jdbc.Driver";

// URL:告訴Java我的數據庫的具體位置(網絡標識:通過什么端口哪臺電腦獲取什么資源)

private static final String CONN_URL = "jdbc:mysql://127.0.0.1:3306/student_db?characterEncoding=UTF-8";

// 用戶名

private static final String CONN_USER_NAME = "root";

// 密碼

private static final String CONN_USER_PASS = "123456";

public static Connection getConn() {

// 創建方法的返回變量

Connection conn = null;

try {

// 1.加載驅動類 讓Java知道我們創建什么數據庫的實例

Class.forName(CONN_DRIVER);

// 通過已經加載好的驅動類給我們提供連接

conn = DriverManager.getConnection(CONN_URL, CONN_USER_NAME,

CONN_USER_PASS);

} catch (ClassNotFoundException e) {

System.out.println("add DriverManager error!");

e.printStackTrace();

} catch (SQLException e) {

System.out.println("SQL error!");

e.printStackTrace();

}

return conn;

}

public static void closeAll(ResultSet set, PreparedStatement ps,

Connection conn) {

try {

if (null != set) {

set.close();

}

if (null != ps) {

ps.close();

}

if (null != conn) {

conn.close();

}

} catch (SQLException e) {

System.out.println("closeAll ERROR!");

e.printStackTrace();

}

}

public static void main(String[] args) {

// 獲取數據庫連接

Connection conn = JDBCUtil.getConn();

Scanner scan = new Scanner(System.in);

while (true) {

System.out.println("請素輸入要查看的數據:");

int i = scan.nextInt();

int start = (i - 1) * 10;

int size = 10;

// 2.編寫SQL語句(查詢id > 0的數據, 連續查詢10條記錄)

String sql = "SELECT * FROM student WHERE s_id LIMIT ?,?";

// SELECT * FROM student WHERE s_id > 10 AND s_id <= (10 + 10)

// 3.運行SQL語句

try {

PreparedStatement ps = conn.prepareStatement(sql);

ps.setInt(1, start);

ps.setInt(2, size);

// 4.執行后返回結果(execute執行Query結果)

ResultSet set = ps.executeQuery();

System.out.println("學生編號\t學生姓名\t學生年齡\t入學時間\t學費");

for (; set.next();) {

System.out.print(set.getInt("S_ID") + "\t");

System.out.print(set.getString("S_NAME") + "\t");

System.out.print(set.getInt("S_AGE") + "\t");

System.out.print(set.getDate("S_INTODATE") + "\t");

System.out.print(set.getDouble("S_MONEY") + "\t");

System.out.println();

}

} catch (SQLException e) {

System.out.println("select error");

e.printStackTrace();

}

}

}

}

2.創建數據庫實體類Student.java文件(Model層)

package com.fyl.entity;

import java.io.Serializable;

import java.util.Date;

/**

* 實體類

* @author Administrator

*

*/

public class Student implements Serializable {

private static final long serialVersionUID = 1L;//添加唯一標識

private Integer id;

private String name;

private int age;

private Date date;

private Double money;

public Integer getId() {

return id;

}

public void setId(Integer id) {

this.id = id;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public int getAge() {

return age;

}

public void setAge(int age) {

this.age = age;

}

public Date getDate() {

return date;

}

public void setDate(Date date) {

this.date = date;

}

public Double getMoney() {

return money;

}

public void setMoney(Double money) {

this.money = money;

}

}

3.index.jsp界面(呈現給用戶的第一個界面)

系統首頁

// 重定向到URL

request.getRequestDispatcher("StudentViewAction").forward(request, response);

%>

4.新建servlet文件StudentViewAction.java(Controller層)

package com.fyl.web;

import java.io.IOException;

import java.io.PrintWriter;

import java.util.List;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import com.fyl.dao.StudentDAO;

import com.fyl.dao.impl.StudentDAOImpl;

import com.fyl.entity.Student;

public class StudentViewAction extends HttpServlet {

private static final long serialVersionUID = 1L;

public void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

doPost(request, response);

}

public void doPost(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

//封裝數據給頁面

//整理頁面需要的數據

int pageIndex = 0;//頁面 //頁面每次請求傳過來的

int pageSize = 10;//

int totalCount = 0;

int totalPge = 0;

List list = null;

//從頁面接收可變的值

String pi = request.getParameter("pageIndex");

//pi有問題的時候,初始化為1

if (null == pi || "".equals(pi)) {

pi = "1";

}

//如果pi沒有問題的時候

pageIndex = Integer.parseInt(pi);

//從數據接收值

StudentDAO dao = new StudentDAOImpl();

//調用DAO方法

totalCount = dao.findStudentListByPageCount();

//計算總頁數

totalPge = totalCount % pageSize == 0?totalCount/pageSize:totalCount/pageSize + 1;

//判斷pageIndex的邊界值

if (pageIndex < 1) {

pageIndex = 1;

}

if (pageIndex > totalPge) {

pageIndex = totalPge;

}

//獲取數據集合

list = dao.findStudentListByPage(pageIndex, pageSize);

//封裝打包頁面

request.setAttribute("pageIndex", pageIndex);

request.setAttribute("pageSize", pageSize);

request.setAttribute("totalCount", totalCount);

request.setAttribute("totalPge", totalPge);

request.setAttribute("list", list);

//轉發頁面

request.getRequestDispatcher("list.jsp").forward(request, response);

}

}

新建list.jsp界面接收StudentViewAction傳來的值

數據展示

function goUpdate(id){

window.location.href = "StudentFindByIDViewAction?id=" + id;

}

function goDelete(id){

var con = window.confirm("您確定刪除ID為" + id + "這條數據嗎?" );

if(con){

//刪除

window.location.href = "StudentDeleteAction?id=" + id;

}

}

function goPage(pageIndex){

window.location.href = "StudentViewAction?pageIndex="+pageIndex;

}

function goPage(pageIndex){

window.location.href = "StudentViewAction?pageIndex="+pageIndex;

}

function goAdd(){

window.location.href = "add.jsp";

}

一共查詢出${totalCount}條數據,每頁展示${pageSize}條,一共有${totalPage}頁,當前瀏覽的是第${pageIndex}頁

學生ID學生姓名學生年齡入學時間學費操作
${s.id}${s.name}${s.age}

||

三. 實現增刪查改

創建接口, 新建StudentDAO.java接口文件, 添加增刪查改方法

package com.fyl.dao;

import java.util.List;

import com.fyl.entity.Student;

public interface StudentDAO {

/**

* 更據id刪除

* @param id

* @return

* @throws RuntimeException

*/

public boolean deleteStudent(Integer id) throws RuntimeException;

/**

* 根據ID查詢單個學生對象

* @param id

* @return

* @throws RuntimeException

*/

public Student findStudentByID(Integer id) throws RuntimeException;

/*

* 添加學生方法

* @param student 要添加的學生

* @return 添加成功返回true 添加失敗返回false

* @throws RuntimeException

*/

public boolean insertStudent(Student student)throws RuntimeException;

/**

* 查詢數據庫的總條數

* @return 總條數

* @throws RuntimeException

*/

public int findStudentListByPageCount() throws RuntimeException;

/**

* 獲取分頁數集合

* @param pageIndex 頁碼

* @param pageSize 頁容量

* @return 已經分頁的list集合

* @throws RuntimeException

*/

public List findStudentListByPage(Integer pageIndex, Integer pageSize) throws RuntimeException;

/*

* 更新學生信息

* @param student

* @return

* @throws RuntimeException

*/

public boolean updateStudent(Student student) throws RuntimeException;

}

2.新建StudentDAOImpl.java文件,實現接口

package com.fyl.dao.impl;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.util.ArrayList;

import java.util.List;

import com.fyl.dao.StudentDAO;

import com.fyl.entity.Student;

import com.fyl.util.JDBCUtil;

public class StudentDAOImpl implements StudentDAO {

// TODO

public int findStudentListByPageCount() throws RuntimeException {

// 1.創建方法的返回變量

int totalCount = 0;

// 3.獲取數據庫連接

Connection conn = JDBCUtil.getConn();

// 4.編寫SQL語句

String sql = "SELECT COUNT(S_ID) FROM STUDENT";

// 執行SQL語句

PreparedStatement ps = null;

ResultSet set = null;

try {

ps = conn.prepareStatement(sql);

set = ps.executeQuery();

//處理

if (set.next()) {

totalCount = set.getInt(1);

}

} catch (SQLException e) {

// TODO

e.printStackTrace();

} finally {

JDBCUtil.closeAll(set, ps, conn);

}

return totalCount;

}

// TODO

public List findStudentListByPage(Integer pageIndex,

Integer pageSize) throws RuntimeException {

List list = new ArrayList();

//2.1獲取數據庫連接

Connection conn = JDBCUtil.getConn();

//3. 創建SQL語句

String sql = "SELECT * FROM STUDENT WHERE S_ID LIMIT ?,?";

//4.執行SQL語句

PreparedStatement ps = null;

ResultSet set = null;

try {

ps = conn.prepareStatement(sql);

ps.setInt(1, (pageIndex-1) * pageSize);

ps.setInt(2, pageSize);

set = ps.executeQuery();

Student s = null;

while (set.next()) {

s = new Student();

//封裝數據

s.setId(set.getInt("S_ID"));

s.setName(set.getString("S_NAME"));

s.setAge(set.getInt("S_AGE"));

s.setMoney(set.getDouble("S_MONEY"));

s.setDate(set.getDate("S_INTODATE"));

// 將封裝好的Student對像裝入集合

list.add(s);

}

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} finally {

JDBCUtil.closeAll(set, ps, conn);

}

return list;

}

public boolean insertStudent(Student student) throws RuntimeException {

// TODO Auto-generated method stub

//1.定義方法返回變量

boolean con = false;

//3. 獲取數據庫連接

Connection conn = JDBCUtil.getConn();

//4. 編寫SQL語句

String sql = "INSERT INTO STUDENT (S_NAME,S_AGE,S_INTODATE,S_MONEY) VALUES (?,?,?,?)";

// 5. 執行SQL語句

PreparedStatement ps = null;

try {

ps = conn.prepareStatement(sql);

// 6. 是否有占位符賦值?

ps.setString(1, student.getName());

ps.setInt(2, student.getAge());

ps.setDate(3, new java.sql.Date(student.getDate().getTime()));

ps.setDouble(4, student.getMoney());

int count = ps.executeUpdate(); // 執行增 刪 改 SQL 返回int類型的受影響行數

// 7. 改變方法的返回值

con = count>0?true:false;

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

// 2. 返回con

return con;

}

// TODO 根據id查詢

public Student findStudentByID(Integer id) throws RuntimeException {

//創建方法的返回值

Student student = null;

Connection conn = JDBCUtil.getConn();

//編寫SQL語句

String sql = "SELECT * FROM STUDENT WHERE S_ID = ?";

//執行SQL語句

PreparedStatement ps = null;

ResultSet set = null;

try {

ps = conn.prepareStatement(sql);

//是否有占位符

ps.setInt(1, id);

set = ps.executeQuery();

if(set.next()){

//創建實例對象封裝查詢數據

student = new Student();

student.setId(set.getInt("S_ID"));

student.setAge(set.getInt("S_AGE"));

student.setDate(set.getDate("S_INTODATE"));

student.setMoney(set.getDouble("S_MONEY"));

student.setName(set.getString("S_NAME"));

}

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}finally{

JDBCUtil.closeAll(set, ps, conn);

}

return student;

}

// TODO 更新學生信息

public boolean updateStudent(Student student) throws RuntimeException {

//創建方法的返回值

boolean con = false;

//獲取數據庫連接

Connection conn = JDBCUtil.getConn();

//編寫SQL語句

String sql = "UPDATE STUDENT SET S_NAME=?,S_AGE=?,S_INTODATE=?,S_MONEY=? WHERE S_ID=?";

//執行SQL語句

PreparedStatement ps = null;

try {

ps = conn.prepareStatement(sql);

//是否有占位符

ps.setString(1, student.getName());

ps.setInt(2, student.getAge());

ps.setDate(3, new java.sql.Date(student.getDate().getTime()));

ps.setDouble(4, student.getMoney());

ps.setInt(5, student.getId());

int count = ps.executeUpdate();

con = count>0?true:false;

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return con;

}

// TODO delete

public boolean deleteStudent(Integer id) throws RuntimeException {

//創建方法的返回變量

boolean con = false;

//獲取數據庫鏈接

Connection conn = JDBCUtil.getConn();

//編寫SQL語句

String sql = "DELETE FROM STUDENT WHERE S_ID = ?";

//執行SQL語句

PreparedStatement ps = null;

try {

ps = conn.prepareStatement(sql);

ps.setInt(1, id);

int count = ps.executeUpdate();

con = count > 0?true:false;

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}finally{

JDBCUtil.closeAll(null, ps, conn);

}

return con;

}

// TODO main

public static void main(String[] args) {

StudentDAO dao = new StudentDAOImpl();

System.out.println(dao.findStudentListByPageCount());

}

}

3.創建servlet文件StudentAddAction.java接收用戶傳入的值,添加到數據庫并展示到list.jsp(增)

package com.fyl.web;

import java.io.IOException;

import java.io.PrintWriter;

import java.text.DateFormat;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Date;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import com.fyl.dao.StudentDAO;

import com.fyl.dao.impl.StudentDAOImpl;

import com.fyl.entity.Student;

public class StudentAddAction extends HttpServlet {

private static final long serialVersionUID = 1L;

public void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

this.doPost(request, response);

}

public void doPost(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

//設置請求來源的編碼

request.setCharacterEncoding("UTF-8");

//1. 接收頁面數據

String studentName = request.getParameter("studentName");

String studentAge = request.getParameter("studentAge");

String intoDate = request.getParameter("intoDate");

String money = request.getParameter("money");

//2. 封裝

Student student = new Student();

student.setName(studentName);

student.setAge(Integer.parseInt(studentAge));

student.setMoney(Double.parseDouble(money));

// String 轉 時間

DateFormat df = new SimpleDateFormat("yyyy-MM-dd");

try {

Date d = df.parse(intoDate);

student.setDate(d);

} catch (ParseException e) {

e.printStackTrace();

}

// 3. 創建DAO層對象添加到數據庫

StudentDAO dao = new StudentDAOImpl();

boolean con = dao.insertStudent(student);

if(con){

// 添加成功

response.sendRedirect("StudentViewAction");

}else{

// 添加失敗

// 通過服務器的響應流主動向客戶端發送信息

response.setCharacterEncoding("UTF-8");

response.setContentType("text/html; charset=UTF-8");

String msg = "";

PrintWriter out = response.getWriter();

out.print(msg);

out.flush();

out.close();

}

}

}

4.創建servlet文件StudentDeleteAction.java接收用戶傳入的值,刪除數據庫中指定文件并展示到list.jsp(刪)

package com.fyl.web;

import java.io.IOException;

import java.io.PrintWriter;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import com.fyl.dao.StudentDAO;

import com.fyl.dao.impl.StudentDAOImpl;

public class StudentDeleteAction extends HttpServlet {

private static final long serialVersionUID = 1L;

public void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

this.doPost(request, response);

}

public void doPost(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

//1. 確定編碼

request.setCharacterEncoding("UTF-8");

//2. 獲取頁面數據

String id = request.getParameter("id");

//3. 創建DAO方法執行刪除

StudentDAO dao = new StudentDAOImpl();

boolean con = dao.deleteStudent(Integer.parseInt(id));

if(con){

//添加成功

response.sendRedirect("StudentViewAction");

}else{

//添加失敗

response.setCharacterEncoding("UTF-8");

response.setContentType("text/html; charset=UTF-8");

String msg = "";

PrintWriter out = response.getWriter();

out.print(msg);

out.flush();

out.close();

}

}

}

創建servlet文件StudentFindByIDViewAction.java接收用戶傳入的值,查詢數據庫中指定文件并展示到list.jsp(查)

package com.fyl.web;

import java.io.IOException;

import java.io.PrintWriter;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import com.fyl.dao.StudentDAO;

import com.fyl.dao.impl.StudentDAOImpl;

import com.fyl.entity.Student;

public class StudentFindByIDViewAction extends HttpServlet {

private static final long serialVersionUID = 1L;

public void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

this.doPost(request, response);

}

public void doPost(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

//設置編碼

request.setCharacterEncoding("UTF-8");

//接收頁面輸入

String id = request.getParameter("id");

//創建DAO層對象

StudentDAO dao = new StudentDAOImpl();

Student student = dao.findStudentByID(new Integer(id));

request.setAttribute("stu", student);

request.getRequestDispatcher("update.jsp").forward(request, response);

}

}

6.創建servlet文件StudentUpdateAction.java接收用戶傳入的值,更新數據庫中指定文件并展示到list.jsp(改)

package com.fyl.web;

import java.io.IOException;

import java.io.PrintWriter;

import java.text.DateFormat;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Date;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import com.fyl.dao.StudentDAO;

import com.fyl.dao.impl.StudentDAOImpl;

import com.fyl.entity.Student;

public class StudentUpdateAction extends HttpServlet {

private static final long serialVersionUID = 1L;

public void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

this.doPost(request, response);

}

public void doPost(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

//設置請求來源的編碼格式

request.setCharacterEncoding("UTF-8");

//1. 設置接收頁面數據

String studentId = request.getParameter("studentId");

String studentName = request.getParameter("studentName");

String studentAge = request.getParameter("studentAge");

String intoDate = request.getParameter("Date");

String money = request.getParameter("money");

//2. 封裝

Student student = new Student();

String studentId1 = studentId.trim();

student.setId(Integer.parseInt(studentId1));

student.setName(studentName);

student.setAge(Integer.parseInt(studentAge));

student.setMoney(Double.parseDouble(money));

//String轉時間

DateFormat df = new SimpleDateFormat("yyyy-MM-dd");

try {

Date d = df.parse(intoDate);

student.setDate(d);

} catch (ParseException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

//3. 創建DAO層對象添加到數據庫

StudentDAO dao = new StudentDAOImpl();

boolean con = dao.updateStudent(student);

if(con)0.{

//添加成功

response.sendRedirect("StudentViewAction");

}else{

//添加失敗

//通過服務器的響應流主動向客戶端發送信息

response.setCharacterEncoding("UTF-8");

response.setContentType("text/html; charset=UTF-8");

String msg = "";

PrintWriter out = response.getWriter();

out.print(msg);

out.flush();

out.close();

}

}

}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/530287.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/530287.shtml
英文地址,請注明出處:http://en.pswp.cn/news/530287.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

java 瀏覽器 安全_安全策略-IE瀏覽器防黑十大秘籍

1.管理好Cookie在IE6.0中&#xff0c;打開“工具”→“Internet選項”→“隱私”對話框&#xff0c;這里設定了“阻止所有Cookie”、“高”、“中高”、“中”、“低”、“接受所有Cookie”六個級別&#xff0c;你只要拖動滑塊就可以方便地進行設定&#xff0c;而點擊下方的“編…

什么是java中的枚舉法_enum枚舉javajava,enum枚舉使用詳解+,總結

enum 的全稱為 enumeration&#xff0c; 是 JDK 1.5 中引入的新特性&#xff0c;存放在 java.lang 包中。下面是我在使用 enum 過程中的一些經驗和總結。原始的接口定義常量語法(定義)創建枚舉類型要使用 enum 關鍵字&#xff0c;隱含了所創建的類型都是 java.lang.Enum 類的子…

java 審計 漏洞函數_Java Web代碼審計流程與漏洞函數

常見框架與組合常見框架Struts2SpringMVCSpring Boot框架執行流程View層&#xff1a;視圖層Controller層&#xff1a;表現層Service層&#xff1a;業務層Dom層&#xff1a;持久層常見組合SpringStruts2HibernateSpringSpringMVCMybatisSpring BootMybatis代碼審計方法根據業務功…

java前期_【JAVA】前期環境配置

一、java的環境配置及在eclipse中如何安裝JRE或JDK環境eclipse下載地址&#xff1a;JDK下載地址&#xff1a;1)安裝JDK或JRE注&#xff1a;JDK使用與開發者運用&#xff0c;其中包含了開發環境和運行環境。而JRE只包含了java的運行環境。2)配置設置執行路徑UNiX&#xff1a;在C…

php截取指定字符串之后,php截取字符串(截取指定字符串之間的字符串)

一、PHP截取兩個指定字符后邊的字符$a "123abc#456";$b (strpos($a,""));$c (strpos($a,"#"));echo substr($a,$b1,$c-1);二、常用截取字符串技巧。//構造字符串$str "ABCDEFGHIJKLMNOPQRSTUVWXYZ";echo "原字符串&#xff1a;…

php 日志按天截取,Laravel 日志管理:按日期切割日志

日志存儲Laravel 默認的錯誤文件記錄在一個文件里&#xff0c;隨著時間的推移&#xff0c;此文件將會變得巨大&#xff0c;不方便查閱。我們可以通過修改 config/app.php 配置文件中的 log 選項來配置 Laravel 使用的存儲機制。如果你希望每天產生日志都存放在不同的文件中&…

php xcache 方法,php xcache 解密

NO.2 /index.php?actionmd5webcrack 很強大,需要登陸論壇才能解密,點擊右上角的“register”進行注冊,都是一些簡單的單詞,應該能看懂吧?...() A.PHP B.JSP D.Ajax 4.配置 ...假設$aarray(‘x’,’y’);,則$aarray_pad...xcache 15 四個模塊 Admin Common Member Article 用戶…

ecshop category.php?id=4,categoryall.php

//by 瑯琊源碼 QQ:27392236define(IN_ECS, true);require dirname(__FILE__) . /includes/init.php;if ((DEBUG_MODE & 2) ! 2) {$smarty->caching true;}require ROOT_PATH . /includes/lib_area.php;$area_info get_area_info($province_id);$area_id $area_info[r…

php 獲取key的位置,PHP獲取當前所在目錄位置的方法

本文實例講述了PHP獲取當前所在目錄位置的方法。分享給大家供大家參考。具體分析如下&#xff1a;如果要獲取腳本文件的目錄&#xff0c;要應用函數getcwd()來實現。函數聲明如下&#xff1a;string getcwd ( void ) ;成功執行后返回當前目錄字符串&#xff0c;失敗返回FALSE。…

java8收集器,Java 8中的收集器collectionAndThen()方法

collectingAndThen()Java Collectors類中的方法使Collector適應于執行其他完成轉換。它返回執行下游收集器動作的收集器&#xff0c;然后執行附加的結束步驟。語法如下。static Collector collectingAndThen(Collector downstream, Functionfinisher)在這里&#xff0c;參數T-…

php 精度運算,PHP BC 庫(任意精度數字運算) | 網游世界

留意&#xff1a;備選參數$scale以設置運算精度(保留小數位)。bcscale(設置運算精度)bool bcscale ( int $scale )說明&#xff1a;設置運算精度(保留小數位)&#xff0c;成功返回TRUE否則為FALSE。bcadd(加法運算)string bcadd ( string $left_operand , string $right_operan…

php 不允許外部訪問,[日常] 解決mysql不允許外部訪問

1.在端口已經開放的情況下,ubuntu mysql 3306允許遠程訪問vim /etc/mysql/mysql.conf.d/mysqld.cnf注釋#bind-address 127.0.0.12.給用戶授權允許遠程訪問:grant all privileges on *.* to root"%" identified by "pwd" with grant option;flush privileg…

elementary安裝Java,elementary os怎么樣安裝java

elementary os的安裝方法elementary os 的安裝鏡像文件準備好以后&#xff0c;這里以虛擬機上安裝為例&#xff0c;配置好以后啟動虛擬機進入安裝界面。在初始化安裝界面中先選擇“中文簡體”&#xff0c;再點擊“安裝elementary os”按鈕隨后系統會顯示硬件安裝需求界面&#…

java jni框架,Java JNI 簡明教程(一)——傳智播客JNI筆記(王澤佑)

package cn.itcast;public calss TestNative {public native void sayHello();public static void main(String[] arg){}}2. 用javah.exe生成包含native方法的C/C頭文件javah -jni(默認)javah cn.itcast.TestNative //由類名執行生成C/C頭文件生成的頭文件內容&#xff1a;JNIE…

java自定義變量解析,Thymeleaf內置對象、定義變量、URL參數及標簽自定義屬性

如標題所述&#xff0c;這篇文章主要講述Thymeleaf中的內置對象(list解析、日期格式化、數字格式化等)、定義變量、獲取URL的參數和在頁面標簽中自定義屬性的應用。如果對Thymeleaf的基本使用、maven依賴等不清楚的可以先閱讀我的另一篇文章《Thymeleaf 之 初步使用》。Control…

linux php curl.so,linux中php如何安裝CURL擴展方法

如果php已經在系統編譯好&#xff0c;后來又需要添加新的擴展。一種方式就是重新完全編譯php&#xff0c;另一種方式就是單獨編譯擴展庫&#xff0c;以extension的形式擴展。下面以安裝curl擴展為例&#xff1a;1、下載curl安裝包。(我的php是4.4.4的&#xff0c;下載最新的cur…

matlab線性拉伸函數,采用線性變換對圖像的每一個像素灰度作線性拉伸-Read.PPT

采用線性變換對圖像的每一個像素灰度作線性拉伸-Read第4章 圖像增強(1) 4.1 圖像增強概述 圖像增強(image enhancement)的定義&#xff1a; 在圖像的獲取過程中&#xff0c;由于多種因素的影響&#xff0c;導致圖像質量退化。圖像增強是對退化圖像的某些特征&#xff0c;如邊緣…

php js 循環對象屬性,js 遍歷對象的屬性的代碼_javascript技巧

如&#xff1a;Function.prototype.addMethodfunction(methodName,func){if(!this.prototype[methodName]){this.prototype[methodName]func;//給原型增加方法&#xff0c;此方法會影響到該類型的實例上}return this.prototype;//返回原型&#xff0c;此類型實例可以進行鏈形調…

php連接數據庫navicat,navicat數據庫如何連接php

第一步&#xff0c;打開Navicat&#xff0c;新建數據庫。第二步&#xff0c;在數據庫中新建表。相關推薦&#xff1a;《Navicat for mysql使用圖文教程》第三步&#xff0c;保存表。第四步&#xff0c;表中添加數據。第五步&#xff0c;打開ide&#xff0c;輸入以下php代碼&…

每日一題:LCR 095.最長公共子序列(DP)

題目描述&#xff1a; 給定兩個字符串 text1 和 text2&#xff0c;返回這兩個字符串的最長 公共子序列 的長度。如果不存在 公共子序列 &#xff0c;返回 0 。 一個字符串的 子序列 是指這樣一個新的字符串&#xff1a;它是由原字符串在不改變字符的相對順序的情況下刪除某些…