throw new Exception("登录失败");用户代码未处理Exception 怎么修改

Default.aspx.cs:

namespace LoginUI
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

    }

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        ///通常,直接使用DAO呼叫数据库。
        //IDbConnection conn = new SqlConnection("C....");
        //IDbCommand cmd=conn.CreateCommand();
        //cmd.CommandText ="Select UserName From USERS WHERE .....";
        //cmd.ExecuteReader();

        //利用三层架构,需要引用下一层的
        string userName = txtUserName.Text.Trim();
        string password = txtPwd.Text;
        LoginBLL.LoginManager mgr = new LoginBLL.LoginManager();
        LoginModel.UserInfo user = mgr.UserLogin(userName, password);

        MessageBox.Show("登录用户:" + user.UserName);
    }
}

}

LoginManager.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace LoginBLL
{
public class LoginManager
{
public LoginModel.UserInfo UserLogin(string userName,string password)
{
//throw new NotImplementedException();
//呼叫数据源,获取相应数据
LoginDAL.UserDAO uDao = new LoginDAL.UserDAO();
LoginModel.UserInfo user = uDao.SelectUser(userName, password);
if(user !=null)//login successful
{
//如果登陆成功,则增加10点积分。
LoginDAL.ScoreDAO sDao = new LoginDAL.ScoreDAO();
sDao.UpdateScore(userName, 10);
return user;
}
else
{
throw new Exception("登录失败");
}
}
}
}

2个回答

 LoginModel.UserInfo user = mgr.UserLogin(userName, password);

->
try
{
LoginModel.UserInfo user = mgr.UserLogin(userName, password);
}
catch
{
MessageBox.Show("登录失败");
}
caozhy
贵阳老马马善福专业维修游泳池堵漏防水工程 回复qq_35905323: 晕,你是asp.net,用alert,不用messagebox
3 年多之前 回复
qq_35905323
qq_35905323 不懂为什么mgr、MessageBox不存在
3 年多之前 回复

else
{
throw new Exception("登录失败");
}

=>

else
{
Response.Write("alert('登录失败')");
}

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
VS中新建了同步类ControlsSynchronizer,但在调试中在BindControls处出现了“未处理的Exception”,请各位大佬帮帮我这个小白!感激不尽
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.IO; using System.Runtime.InteropServices; using ESRI.ArcGIS.esriSystem; using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Controls; using ESRI.ArcGIS.SystemUI; namespace Final { public class ControlsSynchronizer { #region class members private IMapControl3 m_mapControl = null; private IPageLayoutControl2 m_pageLayoutControl = null; private ITool m_mapActiveTool = null; private ITool m_pageLayoutActiveTool = null; private bool m_IsMapCtrlactive = true; private ArrayList m_frameworkControls = null; #endregion #region constructor public ControlsSynchronizer() { m_frameworkControls = new ArrayList(); } public ControlsSynchronizer(IMapControl3 mapControl, IPageLayoutControl2 pageLayeroutControl) : this() { m_mapControl = mapControl; m_pageLayoutControl = pageLayeroutControl; } #endregion #region properties public IMapControl3 MapControl { get { return m_mapControl; } set { m_mapControl = value; } } public IPageLayoutControl2 PageLayoutControl { get { return m_pageLayoutControl; } set { m_pageLayoutControl = value; } } public string ActiveViewType { get { if (m_IsMapCtrlactive) return "MapControl"; else return "PageLayoutControl"; } } public object ActiveControl { get { if (m_mapControl == null || m_pageLayoutControl == null) throw new Exception("ControlsSynchronizer::ActiveControl:\r\nEither MapControl or PageLayoutControl are not initialized!"); if (m_IsMapCtrlactive) return m_mapControl.Object; else return m_pageLayoutControl.Object; } } #endregion #region Methods public void ActivateMap() { try { if (m_pageLayoutControl == null || m_mapControl == null) throw new Exception("ControlsSynchronizer::ActivateMap:\r\nEither MapControl or PageLayoutControl are not initialized!"); if (m_pageLayoutControl.CurrentTool != null) m_pageLayoutActiveTool = m_pageLayoutControl.CurrentTool; m_pageLayoutControl.ActiveView.Deactivate(); m_mapControl.ActiveView.Activate(m_mapControl.hWnd); if (m_mapActiveTool != null) m_mapControl.CurrentTool = m_mapActiveTool; m_IsMapCtrlactive = true; this.SetBuddies(m_mapControl.Object); } catch (Exception ex) { throw new Exception(string.Format("ControlsSynchronizer::ActiveMap:\r\n{0}", ex.Message)); } } public void ActivatePageLayout() { try { if (m_pageLayoutControl == null || m_mapControl == null) throw new Exception("ControlsSynchronizer::ActivatePageLayout:\r\nEither Map Control or PageLayoutControl are not initialized!"); if (m_mapControl.CurrentTool != null) m_mapActiveTool = m_mapControl.CurrentTool; m_mapControl.ActiveView.Deactivate(); m_pageLayoutControl.ActiveView.Activate (m_pageLayoutControl.hWnd); if (m_pageLayoutActiveTool != null) m_pageLayoutControl.CurrentTool = m_pageLayoutActiveTool; m_IsMapCtrlactive = false; this.SetBuddies(m_pageLayoutControl.Object); } catch (Exception ex) { throw new Exception(string.Format("ControlsSynchronizer::ActivatePageLayout:\r\n{0}", ex.Message)); } } public void ReplaceMap(IMap newMap) { if (newMap == null) throw new Exception("ControlsSynchronizer::ReplaceMap:\r\nNew map for replacement is not initialized!"); if (m_pageLayoutControl == null || m_mapControl == null) throw new Exception("ControlsSynchronizer::ReplaceMap:\r\nEither MapControl or PageLayoutControl are not initialized!"); IMaps maps = new Maps(); maps.Add(newMap); bool bIsMapActive = m_IsMapCtrlactive; this.ActivatePageLayout(); m_pageLayoutControl.PageLayout.ReplaceMaps(maps); m_mapControl.Map = newMap; m_pageLayoutActiveTool = null; m_mapActiveTool = null; if (bIsMapActive) { this.ActivateMap(); m_mapControl.ActiveView.Refresh(); } else { this.ActivatePageLayout(); m_pageLayoutControl.ActiveView.Refresh(); } } public void BindControls(IMapControl3 mapControl, IPageLayoutControl2 pageLayoutControl, bool activateMapFirst) { if (mapControl == null || pageLayoutControl == null) throw new Exception("ControlsSynchronizer::BindControls:\r\nEither MapControl or PageLayoutControl are not initialized!"); m_mapControl = MapControl; m_pageLayoutControl = pageLayoutControl; this.BindControls(activateMapFirst); } public void BindControls(bool activateMapFirst) { if (m_pageLayoutControl == null || m_mapControl == null) throw new Exception("ControlsSynchronizer::BindControls:\r\nEither MapControl or PageLayoutControl are not initialized!"); IMap newMap = new MapClass(); newMap.Name = "Map"; IMaps maps = new Maps(); maps.Add(newMap); m_pageLayoutControl.PageLayout.ReplaceMaps(maps); m_mapControl.Map = newMap; m_pageLayoutActiveTool = null; m_mapActiveTool = null; if (activateMapFirst) this.ActivateMap(); else this.ActivatePageLayout(); } public void AddFrameworkControl(object control) { if (control == null) throw new Exception("ControlsSynchronizer::AddFrameworkControl:\r\nAdded control is not initialized!"); m_frameworkControls.Add(control); } public void RemoveFrameworkControl(object control) { if(control == null ) throw new Exception("ControlsSynchronizer::RemoveFrameworkControl:\r\nControl to be removed is not initialized!"); m_frameworkControls.Remove(control); } public void RemoveFrameworkControlAt(int index) { if (m_frameworkControls.Count < index) throw new Exception("ControlsSynchronizer::RemoveFrameworkControlAt:\r\nIndex is out of range!"); m_frameworkControls.RemoveAt(index); } private void SetBuddies(object buddy) { try { if (buddy == null) throw new Exception("ControlsSynchronizer::SetBuddies:\r\nTarget Buddy Control is not initialized!"); foreach (object obj in m_frameworkControls) { if (obj is IToolbarControl) { ((IToolbarControl)obj).SetBuddyControl(buddy); } else if (obj is ITOCControl) { ((ITOCControl)obj).SetBuddyControl(buddy); } } } catch (Exception ex) { throw new Exception(string.Format("ControlsSynchronizer::SetBuddies:\r\n{0}", ex.Message)); } } #endregion } }
重金求解,为什么我接收不到socket服务端返回的信息,代码如下,这个logger.debug("result:"result)为什么总是空,确认了服务端的确返回到了socket,怎样才能正确从socket取到值呢?
这是socket客户端代码 ``` import java.io.BufferedReader; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.Socket; import java.net.UnknownHostException; import java.util.Scanner; public class Client extends Thread { Socket socket = null; public String result = ""; public String in = ""; public Client(String host, int port, String in) { try { in = new String(in.getBytes(),"GBK"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } this.in = in; try { socket = new Socket(host, port); socket.setSoTimeout(1000); } catch (UnknownHostException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } // public void shutDown() throws IOException { // if (socket != null) { // synchronized (socket) { // socket.close(); // } // } // System.out.println("StopClose.shutDown() complete"); // } @Override public void run() { new sendMessThread().start(); super.run(); try { InputStream s = socket.getInputStream(); byte[] buf = new byte[1024]; int len = 0; while ((len = s.read(buf)) != -1) { System.out.println(new String(buf, 0, len)); } } catch (IOException e) { e.printStackTrace(); } } class sendMessThread extends Thread{ @Override public void run() { super.run(); Scanner scanner=null; OutputStream os= null; try { scanner=new Scanner(System.in); os= socket.getOutputStream(); // String in; // do { // in=scanner.next(); // os.write((""+in).getBytes()); // os.flush(); // } while (!in.equals("bye")); for(int i =0;i<1;i++) { os.write((""+in).getBytes()); os.flush(); } BufferedReader rd = new BufferedReader(new InputStreamReader(socket.getInputStream(),"GBK")); String str = ""; System.out.println("RESULT AS FOLLOWING:"); while ((str = rd.readLine()) != null) { System.out.println(str); } // str = rd.readLine(); Client.this.result = str; System.out.println("Client.this.result:"+Client.this.result); rd.close(); } catch (IOException e) { e.printStackTrace(); } scanner.close(); try { os.close(); } catch (IOException e) { e.printStackTrace(); } } } public static void main(String[] args) { // Client clientTest=new Client("88.6.13.66", 13000); // Client clientTest=new Client("127.0.0.1", 1234,""); // clientTest.start(); } } ``` 这是调用的代码 ``` import java.io.BufferedReader; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.Socket; import java.net.UnknownHostException; import java.util.Scanner; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.sql.Connection; import java.sql.Types; import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; public class FaceCheckManage { private final static String DB_ALIAS = "ALIAS";//数据源 private static final String TRXZONE = "trxZone";//输入|地区号 private static final String TYPE = "type";//输入|操作类型 add-注册 check-识别 del-删除 private static final String IMG = "img";//输入|人脸数据 private static final String ID = "id";//输入|编号 private static final String VALUE = "VALUE";//输出|转发数据 public String process(IWFEngine engine, WFActivity activity, WFData wfd, String wfName) throws ParamNotExistException, com.zjft.bpe.stdlib.exception.UnrecognizedScopeException { BizDataModule dm = wfd.getDataModule(); ZjLogger logger = LoggerUtil.getLog(dm.getChannelId(), dm.getTxCode()); ModuleUtil moduleUtil = new ModuleUtil(wfd, wfd.getDataModule(), activity, logger); String trxZone = moduleUtil.getParamValue(TRXZONE); logger.debug("trxZone:"+trxZone); String type = moduleUtil.getParamValue(TYPE); String imgBase64 = moduleUtil.getParamValue(IMG); String id = moduleUtil.getParamValue(ID); Connection conn = wfd.getTxConnection(moduleUtil.getParamValue(DB_ALIAS)); try { /*是否已注册*/ boolean registedFlag = isRegisted(id, conn, logger); if("add".equals(type)&&registedFlag==true) { CommonUtil.setResponseMsg("FFFFF", "用户已注册,请先删除人脸数据", moduleUtil); return "fail"; }else if(("check".equals(type)||"del".equals(type))&&registedFlag==false) { CommonUtil.setResponseMsg("FFFFF", "用户人脸数据未注册", moduleUtil); return "fail"; } } catch (Exception e) { logger.error("查询是否已注册发生异常",e); CommonUtil.setResponseMsg("FFFFF", "查询是否已注册发生异常", moduleUtil); return "fail"; } JSONObject sysParams = null;//系统参数列表 try { //获取人脸识别配置参数 sysParams = getSysParam(type,conn, logger); }catch (TradeException e) { CommonUtil.setResponseMsg("FFFFF", e.getMessage(), moduleUtil); return "fail"; } catch (Exception e) { logger.error("查询人脸识别系统参数发生异常",e); CommonUtil.setResponseMsg("FFFFF", "查询人脸识别系统参数发生异常", moduleUtil); return "fail"; } String ip = sysParams.getString("ip"); String url =sysParams.getString("url"); //组参数 JSONObject paramMap = new JSONObject(); if("add".equals(type)) { paramMap.put("trxZone", trxZone); paramMap.put("programName", "e"); paramMap.put("id", id); paramMap.put("img1", imgBase64); paramMap.put("imgFace1", "50,60,100,120"); paramMap.put("hack1", 1); paramMap.put("customerAgreement", 1); String trxString = "10032"; String jsonString = paramMap.toJSONString(); int length = jsonString.length()+10; String lenString = getLenString(length); String totalString = trxString+lenString+jsonString; logger.debug("totalString:"+totalString); Client client = new Client("88.6.13.66", 13000,totalString); client.start(); String result = client.result; logger.debug("result:"+result); result = result.substring(5,result.length()); moduleUtil.setParamValue(VALUE, result); logger.debug("VALUE:"+result); JSONObject resultJsonObject = JSONObject.parseObject(result); logger.debug("resultJsonObject:"+resultJsonObject); //新增参数 }else if("check".equals(type)) { paramMap.put("trxZone", trxZone); paramMap.put("programName", "e"); paramMap.put("id", id); paramMap.put("img1", imgBase64); paramMap.put("imgFace1", "50,60,100,120"); paramMap.put("threshold", 0.001); paramMap.put("hack1", 1); String trxString = "10034"; String jsonString = paramMap.toJSONString(); int length = jsonString.length()+10; String lenString = getLenString(length); String totalString = trxString+lenString+jsonString; logger.debug("totalString:"+totalString); Client client = new Client("88.6.13.66", 13000,totalString); client.start(); String result = client.result; logger.debug("result:"+result); result = result.substring(5,result.length()); moduleUtil.setParamValue(VALUE, result); logger.debug("VALUE:"+result); JSONObject resultJsonObject = JSONObject.parseObject(result); logger.debug("resultJsonObject:"+resultJsonObject); }else if("del".equals(type)){ paramMap.put("trxZone", trxZone); paramMap.put("programName", "e"); paramMap.put("id", id); String trxString = "10035"; String jsonString = paramMap.toJSONString(); int length = jsonString.length()+10; String lenString = getLenString(length); String totalString = trxString+lenString+jsonString; logger.debug("totalString:"+totalString); try { totalString = new String(totalString.getBytes(),"GBK"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } Client client = new Client("88.6.13.66", 13000,totalString); client.start(); String result = client.result; logger.debug("result:"+result); result = result.substring(5,result.length()); moduleUtil.setParamValue(VALUE, result); logger.debug("VALUE:"+result); JSONObject resultJsonObject = JSONObject.parseObject(result); logger.debug("resultJsonObject:"+resultJsonObject); }else { CommonUtil.setResponseMsg("FFFFF", "错误的操作类型", moduleUtil); return "fail"; } String param = paramMap.toJSONString(); try { param = "params="+URLEncoder.encode(param,"UTF-8"); } catch (UnsupportedEncodingException e) { logger.error("转换为请求数据失败"); return "fail"; } return "ok"; } /** * <p> 函数名:isRegisted </p> * <p> 函数功能:查询该编号用户人脸信息是否已注册 </p> * <p> 处理过程:(描述这个方法的处理逻辑)</p> * <p> 输入参数描述: </p> * <p> 输出参数描述: </p> * <p> 异常处理描述: </p> * <p> 创建信息:liuyuan/2019年6月4日 下午3:29:48/versoin</p> * <p> 修改信息:(修改人名、修改人名.../最后修改时间/修改版本号)</p> * <p> 多个版本修改,则每次新增一行修改信息</p> * @throws Exception */ private boolean isRegisted(String id,Connection conn,ZjLogger logger) throws Exception { String sql = "select t.id from USER_FACE_RECORD t where t.id_number=? or t.user_no=?"; List<SQLPara> sqlParas = new ArrayList<>(); sqlParas.add(new SQLPara("id_number", Types.VARCHAR, id)); sqlParas.add(new SQLPara("user_no", Types.VARCHAR, id)); CachedRowSet rlt = DbOperate.executeQueryByParamName(sql, sqlParas, conn, logger); return rlt.next(); } /** * * <p>Title: getSysParam</p> * <p>Description: 查询人脸识别相关参数 </p> * @param type * @param conn * @param logger * @return * @throws TradeException * @throws Exception */ private JSONObject getSysParam(String type,Connection conn, ZjLogger logger) throws TradeException,Exception { JSONObject sysParam = new JSONObject(); String qrySysParamSQL = " select t.param_value from SYS_PARAM t where t.param_name=? "; List<SQLPara> sqlParas = new ArrayList<>(); // 查询ip sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_ip")); CachedRowSet ipRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!ipRlt.next()) { throw new TradeException("请先配置人脸识别服务器地址(faceCheck_ip)"); } sysParam.put("ip",ipRlt.getString("param_value")); sqlParas.clear(); // 查询url sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_url")); CachedRowSet urlRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!urlRlt.next()) { throw new TradeException("请先配置人脸识别转发url(faceCheck_url)"); } sysParam.put("url",urlRlt.getString("param_value")); sqlParas.clear(); // 查询baseFlag sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_baseFlag")); CachedRowSet baseFlagRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!baseFlagRlt.next()) { throw new TradeException("请先配置人脸识基准照标示(faceCheck_baseFlag)"); } sysParam.put("baseFlag",baseFlagRlt.getInt("param_value")); sqlParas.clear(); // 查询threshold sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_threshold")); CachedRowSet thresholdRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!thresholdRlt.next()) { throw new TradeException("请先配置人脸识误识率阈值(faceCheck_threshold)"); } sysParam.put("threshold",thresholdRlt.getString("param_value")); sqlParas.clear(); //查询channel sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_channel")); CachedRowSet channelRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!channelRlt.next()) { throw new TradeException("请先配置人脸识别转发业务渠道编号(faceCheck_channel)"); } sysParam.put("channel",channelRlt.getString("param_value")); sqlParas.clear(); //交易编号写死,加操作类型大写进行区分 sysParam.put("trCode","SXFH-BF-SWXJ-ITMS-FACE-"+type.toUpperCase()); //查询appName sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_appName")); CachedRowSet appNameRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!appNameRlt.next()) { throw new TradeException("请先配置人脸识别应用名(faceCheck_appName)"); } sysParam.put("appName",appNameRlt.getString("param_value")); sqlParas.clear(); //查询appInfo sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_appInfo")); CachedRowSet appInfoRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!appInfoRlt.next()) { throw new TradeException("请先配置人脸识别客户端APP信息(faceCheck_appInfo)"); } sysParam.put("appInfo",appInfoRlt.getString("param_value")); sqlParas.clear(); //查询retentionTime sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_retentionTime")); CachedRowSet retentionTimeRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!retentionTimeRlt.next()) { throw new TradeException("请先配置人脸识清理时间(faceCheck_retentionTime)"); } sysParam.put("retentionTime",retentionTimeRlt.getString("param_value")); sqlParas.clear(); logger.debug("sysParam:"+sysParam); return sysParam; } public String getLenString (int length) { NumberFormat formatter = NumberFormat.getNumberInstance(); formatter.setMinimumIntegerDigits(5); formatter.setGroupingUsed(false); String lenString = formatter.format(length); return lenString; } } ``` 这个地方为什么总是空的 ![图片说明](https://img-ask.csdn.net/upload/201912/12/1576144606_651895.png)
java中有返回值的函数中throw new exception会给函数返回值吗?返回值是什么?
java中有返回值的函数中throw new exception会给函数返回值吗?返回值是什么?
获得一个流对象,用类加载器方式和用new方式有什么不同?
第一种: ``` public static InputStream openStream(String resource) { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); InputStream stream = classLoader.getResourceAsStream(resource); if (stream == null) { stream = StreamHelper.class.getClassLoader().getResourceAsStream(resource); } return stream; } ``` 第二种: ``` public static InputStream getStreamFromFile(File file) throws Exception { InputStream stream = null; try { if (!file.exists()) { throw new Exception("file " + file + " doesn't exist"); } if (file.isDirectory()) { throw new Exception("file " + file + " is a directory"); } stream = new FileInputStream(file); } catch (Exception e) { throw new Exception("couldn't access file " + file + ": " + e.getMessage()); } return stream; } ```
Fortify检测sql注入问题 order by动态拼接注入漏洞
java服务,使用spring jdbc做持久化层,数据库使用oracle,在做分页sql拼接的代码被Fortify检测出来问题,甲方要求必须整改。 检测代码源如下: ``` private static String getPagerSql(String sourceSql, Pager<Map<String, Object>> pager) { StringBuffer toSql = new StringBuffer(); toSql.append("select * from ( select row_.*, rownum rownum_ from ( "); toSql.append(sourceSql); toSql.append(" order by "); for (Sort orderBy : pager.getSort()) { toSql.append(String.format("%s %s,", orderBy.getProperty(), orderBy.getDir())); } toSql.deleteCharAt(toSql.length() - 1); toSql.append(" ) row_ ) where rownum_ > ? and rownum_ <= ? "); return toSql.toString(); } ``` 主要问题是在动态拼接排序参数被检测出来问题,虽然排序参数做了排序字段和排序顺序过滤,但还是被检测出高危注入漏洞,代码如下: ``` /** * 获取排序参数 * @return */ public List<Sort> getSort() { String[] sortnames=this.getSortname().split(","); String[] sortordes=this.getSortorder().split(","); if(sortnames.length!=sortordes.length) { throw new IllegalArgumentException("分页多重排序参数中,排序字段与排序方向的个数不相等"); } String regex = "^[a-z0-9A-Z_]{1,20}"; for(String sortname:sortnames) { if(!sortname.matches(regex)) { throw new IllegalArgumentException("分页排序参数中,排序字段非法"); } } List<Sort> orders = new ArrayList<Sort>(); for (int i = 0; i < sortnames.length; i++) { if(!(Sort.ASC.equals(sortordes[i].toLowerCase())||Sort.DESC.equals(sortordes[i].toLowerCase()))) { throw new IllegalArgumentException("分页排序参数中,排序方向非法"); } orders.add(new Sort(sortnames[i], sortordes[i])); } return orders; } ``` 请问有什么办法解决这个被Fortify检测出来的漏洞 ![图片说明](https://img-ask.csdn.net/upload/202002/06/1580969810_309316.jpg)
spring boot 2.1.1,@Transactional注释无法启动事务回滚
``` @Transactional public BooleanMessage importUserOne(String ppUserId) { deleteOneUser(ppUserId); transferOneUser(ppUserId); return BooleanMessage.getSuccessMessage("同步成功!"); } @Transactional public void deleteOneUser(String userid) { try { // 删除:用户 this.deleteUsers(userid); } catch (Exception e) { throw new RuntimeException("delete error : "+e.getMessage()); } } public void deleteUsers(String userid) { dd用户Service.delete(userid); } public boolean delete(String ppUserId) { return ddMapper.deleteByPrimaryKey(ppUserId) == 1; } @Transactional public void transferOneUser(String userid) { try { // 迁移:用户 dd用户Service.transferUsers(findOne(userid)); } catch (Exception e) { throw new RuntimeException("transferOneUser error : "+e.getMessage()); } } @Transactional public void transferUsers(Users one) { if (one == null) { throw new NullPointerException("Users is null!"); } try { String userid = one.getUserid() == null ? "" : one.getUserid(); 用户 mm用户 = new 用户(); mm用户.set用户id(userid); this.add(mm用户); } catch (Exception e) { throw new RuntimeException("users add error : "+e.getMessage()); } } public boolean add(用户 mm用户) { return ddMapper.insert(mm用户) == 1; } ``` ``` import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; import org.springframework.context.annotation.ComponentScan; @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class,DataSourceTransactionManagerAutoConfiguration.class, MybatisAutoConfiguration.class}) @SpringBootApplication @ComponentScan(basePackages={"importdata.*"}) public class BshImportdataApplication { public static void main(String[] args) { SpringApplication.run(BshImportdataApplication.class, args); } } ```我在spring boot 2.1.1版本中,在service层中的方法上加上@Transactional的注解, 没办法启动这个方法的事务回滚,里面的方法执行一半出错也不会回滚成没执行之前的一样,求大神解决
Spring 事务嵌套问题 Propagation.REQUIRES_NEW
``` @Transactional(propagation=Propagation.REQUIRED) public void insertEmploye(Employe emp) { this.getSqlSession().insert("insert", emp); this.updateDep(emp); throw new Exception("My Exception"); } @Transactional(propagation=Propagation.REQUIRES_NEW) public void updateDep(Employe emp){ this.getSqlSession().update("updateCount", emp); } ``` 请问为什么updatedCount没有更新 Propagation.REQUIRES_NEW 不是启动新的事务 隔离外围的吗?
C#System.Data.OleDb.OleDbException:“标准表达式中数据类型不匹配。”
第一段出了错误, 把try,catch删了是da的System.Data.OleDb.OleDbException:“标准表达式中数据类型不匹配。” 刚开始撸完全搞不懂为啥 求大佬解惑 ``` class Class1 { public DataTable ExecuteDataTable(string sql) { try { using (OleDbConnection conn = new OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = 'C:/Users/Lenovo/Desktop/学生选课管理信息系统.mdb'")) { if (conn.State != ConnectionState.Open) conn.Open(); using (OleDbDataAdapter da = new OleDbDataAdapter(sql, conn)) { DataTable dt = new DataTable(); da.Fill(dt); return dt; } } } catch (Exception e) { throw new Exception(e.Message); } } public void ExecuteNonQuery(string sql) { using (OleDbConnection connection = new OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; 'Data Source = C:/Users/Lenovo/Desktop/学生选课管理信息系统.mdb'")) { OleDbCommand command = new OleDbCommand(sql); command.Connection = connection; command.Connection = connection; try { connection.Open(); command.ExecuteNonQuery(); } catch (Exception E) { throw new Exception(E.Message); } } } } ```
关于System.out.write(int b)
这行代码我尝试读源码,发现这样一段 ``` //FilterOutputStream.java public void write(int b) throws IOException { out.write(b); } ``` 进一步跟踪 ``` //OutputStream.java private void ensureOpen() throws IOException { if (this.closed) { throw new IOException("Stream closed"); } } public void write(int b) throws IOException { this.ensureOpen(); } ``` 然而这段代码并没有使用参数b。有没有大佬能解答我的疑问。
Java中直接使用System.getProperty和通过安全控制器获取属性值有什么区别吗?
```//下面的代码来自hashmap,事实上直接使用getProperty也不会受到权限限制 static { String altThreshold = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction( "jdk.map.althashing.threshold")); int threshold; try { threshold = (null != altThreshold) ? Integer.parseInt(altThreshold) : ALTERNATIVE_HASHING_THRESHOLD_DEFAULT; // disable alternative hashing if -1 if (threshold == -1) { threshold = Integer.MAX_VALUE; } if (threshold < 0) { throw new IllegalArgumentException("value must be positive integer."); } } catch(IllegalArgumentException failed) { throw new Error("Illegal value for 'jdk.map.althashing.threshold'", failed); } ALTERNATIVE_HASHING_THRESHOLD = threshold; } ```
python更新pip失败,困扰了我好久
更新pip老是出现下列一大串的文字,我在网上查了许多方法,都没用,有哪位大佬能说一下有什么方法解决这个问题。 这是使用管理员的运行 C:\Windows\system32>python -m pip install --upgrade pip WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/pip/ Collecting pip Downloading https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl (1.4MB) |█████████████████████▌ | 962kB 2.9kB/s eta 0:02:44ERROR: Exception: Traceback (most recent call last): File "D:\Program Files\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 397, in _error_catcher yield File "D:\Program Files\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 479, in read data = self._fp.read(amt) File "D:\Program Files\python\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 62, in read data = self.__fp.read(amt) File "D:\Program Files\python\lib\http\client.py", line 454, in read n = self.readinto(b) File "D:\Program Files\python\lib\http\client.py", line 498, in readinto n = self.fp.readinto(b) File "D:\Program Files\python\lib\socket.py", line 669, in readinto return self._sock.recv_into(b) File "D:\Program Files\python\lib\ssl.py", line 1241, in recv_into return self.read(nbytes, buffer) File "D:\Program Files\python\lib\ssl.py", line 1099, in read return self._sslobj.read(len, buffer) socket.timeout: The read operation timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "D:\Program Files\python\lib\site-packages\pip\_internal\cli\base_command.py", line 188, in main status = self.run(options, args) File "D:\Program Files\python\lib\site-packages\pip\_internal\commands\install.py", line 345, in run resolver.resolve(requirement_set) File "D:\Program Files\python\lib\site-packages\pip\_internal\legacy_resolve.py", line 196, in resolve self._resolve_one(requirement_set, req) File "D:\Program Files\python\lib\site-packages\pip\_internal\legacy_resolve.py", line 359, in _resolve_one abstract_dist = self._get_abstract_dist_for(req_to_install) File "D:\Program Files\python\lib\site-packages\pip\_internal\legacy_resolve.py", line 305, in _get_abstract_dist_for abstract_dist = self.preparer.prepare_linked_requirement( File "D:\Program Files\python\lib\site-packages\pip\_internal\operations\prepare.py", line 195, in prepare_linked_requirement unpack_url( File "D:\Program Files\python\lib\site-packages\pip\_internal\download.py", line 1058, in unpack_url unpack_http_url( File "D:\Program Files\python\lib\site-packages\pip\_internal\download.py", line 920, in unpack_http_url from_path, content_type = _download_http_url(link, File "D:\Program Files\python\lib\site-packages\pip\_internal\download.py", line 1152, in _download_http_url _download_url(resp, link, content_file, hashes, progress_bar) File "D:\Program Files\python\lib\site-packages\pip\_internal\download.py", line 861, in _download_url hashes.check_against_chunks(downloaded_chunks) File "D:\Program Files\python\lib\site-packages\pip\_internal\utils\hashes.py", line 75, in check_against_chunks for chunk in chunks: File "D:\Program Files\python\lib\site-packages\pip\_internal\download.py", line 829, in written_chunks for chunk in chunks: File "D:\Program Files\python\lib\site-packages\pip\_internal\utils\ui.py", line 156, in iter for x in it: File "D:\Program Files\python\lib\site-packages\pip\_internal\download.py", line 794, in resp_read for chunk in resp.raw.stream( File "D:\Program Files\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 531, in stream data = self.read(amt=amt, decode_content=decode_content) File "D:\Program Files\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 496, in read raise IncompleteRead(self._fp_bytes_read, self.length_remaining) File "D:\Program Files\python\lib\contextlib.py", line 131, in __exit__ self.gen.throw(type, value, traceback) File "D:\Program Files\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 402, in _error_catcher raise ReadTimeoutError(self._pool, None, 'Read timed out.') pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. WARNING: You are using pip version 19.2.3, however version 20.0.2 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Throw the Stones 丢石头的问题
Problem Description   Remember our childhood? A few naked children throw stones standing on the same position, the one throws farther win the game. Aha, of course, there are some naughty boys who care more about whether they can urinate father.   You believe it or not, anyway, I believed. Nowadays, some of the children are smarter than we were, while others may be more naughty.   A week ago, I saw several children throw stones. In fact, they are more clever than we were, since the game they played, apparently, is more complex than we did. Maybe you have different points of view, however, you’d better learn about the rules of the game before expressing your views. A group of children take turns to throw stones standing on the same position. After some child throw a stone, the children will draw a convex polyhedron with smallest volume together to enclose all the stones thrown by them. You may assume that the stone is so small as to be abstracted as a point in three-dimensional space. Naively, the children regard the space enclosed by the convex polyhedron as territory under their control. After a child throw his stone, the score he obtains equals the incremental of the volume of their territory. Unfortunately, the first three child’s score will always be zero. At last, the child with the highest score will win the game, and known as the "King".   I think you have accepted my opinion already, for the rules of their throwing stones game are really complicated. But, you also don’t need to be frustrated for it. Now, in order to show you are smarter, maybe you can write a program to help the children point out their "King". Input   Input consists of a number of cases. The data of each case appears on a number of input lines, the first of which contains an integer N. The following N lines contain three number (xi, yi, zi) indicating coordinates of the stone thrown by the i-th child. Note: 1 <= N <= 10^4, 1 <= i <= N, -10^4 <= xi , yi , zi <= 10^4. Output   For each test case, you should output two lines. The first line is "Case #K:", K means the number of the test case. The second line is "i v", i means index of the "King" and v means the score of the "King". If there are more than one "King", output the one throws stone earlier than others.   Please round the result to 2 digits after decimal point if necessary. Sample Input 4 1 0 0 1 1 0 0 1 0 0 0 1 5 1 0 0 1 1 0 0 1 0 0 0 0 0 0 1 Sample Output Case #1: 4 0.17 Case #2: 5 0.33
RuntimeException源码
throw new RuntimeException("Stub!"); 几乎所有的android源码实现都有throw new RuntimeException("Stub!");这么一段代码, 我在自学android,发现看不太懂,举个简单的例子 public boolean startActivityIfNeeded(Intent intent, int requestCode) { throw new RuntimeException("Stub!"); } 这个方法的返回值为boolean,是怎么返回的呢?
字节流复制图片的问题,报错,复制失败,图片损坏而且为0 kb
import java.io.*; class Lee{ public static void main (String[] args){ FileOutputStream fos=null; FileInputStream fis=null; try{ fos=new FileOutputStream("D:\\毕向东视频\\9.png"); fis=new FileInputStream("D:\\毕向东视频\\99.png"); byte [] buf=new byte[1024]; int len=0; while((len=fis.read(buf))!=-1) { fos.write(buf,0,len); } } catch(IOException e){ throw new RuntimeException("复制失败"); } finally{ try{ if(fis!=null) fis.close(); } catch(IOException e){ throw new RuntimeException("读取失败"); } } } }
Socket请求第三方接口返回值有很多NUL
请求的代码 ``` public static synchronized String socketPost(String clientIp, String clientPort, String xml, String filePath) throws Exception { String rs = ""; System.out.println(xml); if (clientIp == null || "".equals(clientIp) || clientPort == null || "".equals(clientPort)) { throw new Exception("数据同步地址信息有误,请联系管理员!"); } int clientPortInt = Integer.parseInt(clientPort); logger.info("clientIp:" + clientIp + " clientPort:" + clientPort); Socket s = null; OutputStream out = null; InputStream in = null; try { s = new Socket(clientIp, clientPortInt); s.setSendBufferSize(8192); s.setReceiveBufferSize(8192); s.setTcpNoDelay(true); s.setSoTimeout(30000); s.setKeepAlive(true); out = s.getOutputStream(); in = s.getInputStream(); out.write(xml.getBytes("GBK")); out.flush(); if (in.available() > 0) { Thread.sleep(100); } //前8字节报文长度 byte[] byte8 = new byte[8]; in.read(byte8); logger.info("===========================前8字节报文长度" + new String(byte8)); Integer int8 = Integer.parseInt(new String(byte8, "GBK")); logger.info("===========================" + int8); //报文正文 byte[] byteXml = new byte[int8]; in.read(byteXml); rs = new String(byteXml, "GBK"); logger.info("===========================报文正文" + rs); //后续报文标记3位 byte[] byteEnd = new byte[3]; in.read(byteEnd); String strEnd = new String(byteEnd, "GBK"); logger.info("===========================后续报文标记3位" + strEnd); if(strEnd.equals("FIL")){ //30位文件名 byte[] byte30 = new byte[30]; in.read(byte30); String fileName = new String(byte30, "GBK").trim(); if(StringUtils.isBlank(fileName)){ fileName = UUID.randomUUID().toString()+".jpg"; } logger.info("==========================="+fileName); //前8字节文件长度 byte8 = new byte[8]; in.read(byte8); int8 = Integer.parseInt(new String(byte8,"GBK")); logger.info("==========================="+int8); //文件 byte[] byteFile = readStream(in,int8); //本地文件 File fileDir = new File(filePath); if(!fileDir.exists()||!fileDir.isDirectory()) { fileDir.mkdirs(); } File file = new File(filePath + File.separatorChar + fileName); FileOutputStream fos = new FileOutputStream(file); fos.write(byteFile); fos.flush(); fos.close(); } ``` 返回值开始的一部分数据是正常的剩下的就全是NUL ![图片说明](https://img-ask.csdn.net/upload/201912/28/1577495910_273518.jpg)
java做链表队列增删节点的时候报错,只列出了链表部分,和主程序部分,刚刚入门java,很多地方不懂,求教
import java.util.NoSuchElementException; public class ListQueue<T> implements MyQueue<T> { private class Node { T item; Node next; public Node(T item) { this.item=item; } } private Node head = null; private Node tail = null; // root node private int size = 0; public boolean isEmpty() { return size == 0; } public int size() { return size; } public void enqueue(T item) { Node temptail = new Node(item); if (isEmpty()) { tail = temptail; } else { tail.next = temptail; } size++; } /** * dequeue: remove and return the head of the queue * * @return the deleted value * @throws NoSuchElementException if queue is empty */ public T dequeue() { if (isEmpty()) { throw new NoSuchElementException("the list is empty, cannot be taken data"); } else if (size()==1) { // when list just only has one elements head = null; } else { head = head.next; } size--; return null; } /** * peek: view the head of queue without removing it. * * @return Null if queue is empty */ public T peek() { // if array is empty, cannot view its head if (isEmpty()) { return null; } return head.item; } } public class Driver{ public static void main(String[] args) { MyQueue<Integer> q; boolean useList = true; // make it false if you want to array implementation if (useList) q = new ListQueue<Integer>(); else q = new ArrayQueue<Integer>(); for(int i = 0; i < 1000; i++) // add a large number of items onto the queue { q.enqueue(i); } System.out.println("now, dequeue items!"); while(!q.isEmpty()) { System.out.print(q.dequeue() + " "); } System.out.println("end of dequeueing"); } } //运行程序以后错误是now, dequeue items! Exception in thread "main" java.lang.NullPointerException at yao.as1.ListQueue.dequeue(ListQueue.java:73) at yao.as1.Driver.main(Driver.java:24) 还请给点思路
如何将以下throw 语句更改为try catch?
public static String changeF2Y(String amount) throws Exception { amount = amount.trim(); if (!amount.matches(CURRENCY_FEN_REGEX)) { throw new Exception("金额格式有误"); } amount = BigDecimal.valueOf(Long.valueOf(amount)).divide(new BigDecimal(100)).toString(); if(!amount.contains(".")){ amount = amount + ".00"; } return amount; }
C#新手:关于抛出异常?
throw new Exception("输入有误"); 这个是当输入当有误时候出现的异常。 请问如何将“输入有误”这句话输出在控制台?在不使用try,catch的情况下,仅仅使用throw。
SSH框架的UndeclaredThrowableException问题
我正在学习SSH框架,用到了struts的异常捕获机制。我自定义了一个异常类型,在异常处理类里面通过判断是否是这个类的实例来进行不同的处理。可是我能接受到的异常,全部是UndeclaredThrowableException,这个何解?一下是抛出事件的类: `public class LoginInterceptor implements MethodBeforeAdvice { public void before(Method method, Object[] args, Object instance) throws Exception { ActionMapping mapping = (ActionMapping) args[0]; ActionForm form = (ActionForm) args[1]; HttpServletRequest request = (HttpServletRequest) args[2]; HttpServletResponse response = (HttpServletResponse) args[3]; boolean needsCheck = true; if (needsCheck && PersonUtil.getPersonInfo(request, response) == null) { throw new TempException("您还没有登录"); } } }` 一下是处理异常的类 public class ForumExceptionHandler extends ExceptionHandler { @Override public ActionForward execute(Exception ex, ExceptionConfig ae, ActionMapping mapping, ActionForm formInstance, HttpServletRequest request, HttpServletResponse response) throws ServletException { System.out.println((ex.getClass()) + " aaaaaaa"); System.out.println((ae) + " aaaaaaa"); request.setAttribute("exception", ex); if (ex instanceof AccountException) { return new ActionForward("login", "/index.jsp", false); } return new ActionForward("exception", "/pages/exception.jsp", false); } } 一下是配置文件: <global-exceptions> <exception key="login" type="com.forum.exception.TempException" handler="com.forum.exception.ForumExceptionHandler"> </exception> <exception key="login" type="javax.security.auth.login.AccountException" handler="com.forum.exception.ForumExceptionHandler"> </exception> <exception key="login" type="java.lang.Exception" handler="com.forum.exception.ForumExceptionHandler"> </exception> </global-exceptions>
终于明白阿里百度这样的大公司,为什么面试经常拿ThreadLocal考验求职者了
点击上面↑「爱开发」关注我们每晚10点,捕获技术思考和创业资源洞察什么是ThreadLocalThreadLocal是一个本地线程副本变量工具类,各个线程都拥有一份线程私有的数
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
此博客仅为我业余记录文章所用,发布到此,仅供网友阅读参考,如有侵权,请通知我,我会删掉。 补充 有不少读者留言说本文章没有用,因为天气预报直接打开手机就可以收到了,为何要多此一举发送到邮箱呢!!!那我在这里只能说:因为你没用,所以你没用!!! 这里主要介绍的是思路,不是天气预报!不是天气预报!!不是天气预报!!!天气预报只是用于举例。请各位不要再刚了!!! 下面是我会用到的两个场景: 每日下
面试官问我:什么是消息队列?什么场景需要他?用了会出现什么问题?
你知道的越多,你不知道的越多 点赞再看,养成习惯 GitHub上已经开源 https://github.com/JavaFamily 有一线大厂面试点脑图、个人联系方式,欢迎Star和完善 前言 消息队列在互联网技术存储方面使用如此广泛,几乎所有的后端技术面试官都要在消息队列的使用和原理方面对小伙伴们进行360°的刁难。 作为一个在互联网公司面一次拿一次Offer的面霸,打败了无数
8年经验面试官详解 Java 面试秘诀
    作者 | 胡书敏 责编 | 刘静 出品 | CSDN(ID:CSDNnews) 本人目前在一家知名外企担任架构师,而且最近八年来,在多家外企和互联网公司担任Java技术面试官,前后累计面试了有两三百位候选人。在本文里,就将结合本人的面试经验,针对Java初学者、Java初级开发和Java开发,给出若干准备简历和准备面试的建议。   Java程序员准备和投递简历的实
究竟你适不适合买Mac?
我清晰的记得,刚买的macbook pro回到家,开机后第一件事情,就是上了淘宝网,花了500元钱,找了一个上门维修电脑的师傅,上门给我装了一个windows系统。。。。。。 表砍我。。。 当时买mac的初衷,只是想要个固态硬盘的笔记本,用来运行一些复杂的扑克软件。而看了当时所有的SSD笔记本后,最终决定,还是买个好(xiong)看(da)的。 已经有好几个朋友问我mba怎么样了,所以今天尽量客观
程序员一般通过什么途径接私活?
二哥,你好,我想知道一般程序猿都如何接私活,我也想接,能告诉我一些方法吗? 上面是一个读者“烦不烦”问我的一个问题。其实不止是“烦不烦”,还有很多读者问过我类似这样的问题。 我接的私活不算多,挣到的钱也没有多少,加起来不到 20W。说实话,这个数目说出来我是有点心虚的,毕竟太少了,大家轻喷。但我想,恰好配得上“一般程序员”这个称号啊。毕竟苍蝇再小也是肉,我也算是有经验的人了。 唾弃接私活、做外
大学四年自学走来,这些珍藏的「实用工具/学习网站」我全贡献出来了
知乎高赞:文中列举了互联网一线大厂程序员都在用的工具集合,涉及面非常广,小白和老手都可以进来看看,或许有新收获。
《阿里巴巴开发手册》读书笔记-编程规约
Java编程规约命名风格 命名风格 类名使用UpperCamelCase风格 方法名,参数名,成员变量,局部变量都统一使用lowerCamelcase风格 常量命名全部大写,单词间用下划线隔开, 力求语义表达完整清楚,不要嫌名字长 ...
Python爬虫爬取淘宝,京东商品信息
小编是一个理科生,不善长说一些废话。简单介绍下原理然后直接上代码。 使用的工具(Python+pycharm2019.3+selenium+xpath+chromedriver)其中要使用pycharm也可以私聊我selenium是一个框架可以通过pip下载 pip install selenium -i https://pypi.tuna.tsinghua.edu.cn/simple/ 
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
你知道的越多,你不知道的越多 点赞再看,养成习惯 本文 GitHub https://github.com/JavaFamily 已收录,有一线大厂面试点思维导图,也整理了很多我的文档,欢迎Star和完善,大家面试可以参照考点复习,希望我们一起有点东西。 前前言 为啥今天有个前前言呢? 因为你们的丙丙啊,昨天有牌面了哟,直接被微信官方推荐,知乎推荐,也就仅仅是还行吧(心里乐开花)
Java工作4年来应聘要16K最后没要,细节如下。。。
前奏: 今天2B哥和大家分享一位前几天面试的一位应聘者,工作4年26岁,统招本科。 以下就是他的简历和面试情况。 基本情况: 专业技能: 1、&nbsp;熟悉Sping了解SpringMVC、SpringBoot、Mybatis等框架、了解SpringCloud微服务 2、&nbsp;熟悉常用项目管理工具:SVN、GIT、MAVEN、Jenkins 3、&nbsp;熟悉Nginx、tomca
Python爬虫精简步骤1 获取数据
爬虫的工作分为四步: 1.获取数据。爬虫程序会根据我们提供的网址,向服务器发起请求,然后返回数据。 2.解析数据。爬虫程序会把服务器返回的数据解析成我们能读懂的格式。 3.提取数据。爬虫程序再从中提取出我们需要的数据。 4.储存数据。爬虫程序把这些有用的数据保存起来,便于你日后的使用和分析。 这一篇的内容就是:获取数据。 首先,我们将会利用一个强大的库——requests来获取数据。 在电脑上安装
Python绘图,圣诞树,花,爱心 | Turtle篇
1.画圣诞树 import turtle screen = turtle.Screen() screen.setup(800,600) circle = turtle.Turtle() circle.shape('circle') circle.color('red') circle.speed('fastest') circle.up() square = turtle.Turtle()
作为一个程序员,CPU的这些硬核知识你必须会!
CPU对每个程序员来说,是个既熟悉又陌生的东西? 如果你只知道CPU是中央处理器的话,那可能对你并没有什么用,那么作为程序员的我们,必须要搞懂的就是CPU这家伙是如何运行的,尤其要搞懂它里面的寄存器是怎么一回事,因为这将让你从底层明白程序的运行机制。 随我一起,来好好认识下CPU这货吧 把CPU掰开来看 对于CPU来说,我们首先就要搞明白它是怎么回事,也就是它的内部构造,当然,CPU那么牛的一个东
破14亿,Python分析我国存在哪些人口危机!
2020年1月17日,国家统计局发布了2019年国民经济报告,报告中指出我国人口突破14亿。 猪哥的朋友圈被14亿人口刷屏,但是很多人并没有看到我国复杂的人口问题:老龄化、男女比例失衡、生育率下降、人口红利下降等。 今天我们就来分析一下我们国家的人口数据吧! 更多有趣分析教程,扫描下方二维码关注vx公号「裸睡的猪」 即可查看! 一、背景 1.人口突破14亿 2020年1月17日,国家统计局发布
听说想当黑客的都玩过这个Monyer游戏(1~14攻略)
第零关 进入传送门开始第0关(游戏链接) 请点击链接进入第1关: 连接在左边→ ←连接在右边 看不到啊。。。。(只能看到一堆大佬做完的留名,也能看到菜鸡的我,在后面~~) 直接fn+f12吧 &lt;span&gt;连接在左边→&lt;/span&gt; &lt;a href="first.php"&gt;&lt;/a&gt; &lt;span&gt;←连接在右边&lt;/span&gt; o
在家远程办公效率低?那你一定要收好这个「在家办公」神器!
相信大家都已经收到国务院延长春节假期的消息,接下来,在家远程办公可能将会持续一段时间。 但是问题来了。远程办公不是人在电脑前就当坐班了,相反,对于沟通效率,文件协作,以及信息安全都有着极高的要求。有着非常多的挑战,比如: 1在异地互相不见面的会议上,如何提高沟通效率? 2文件之间的来往反馈如何做到及时性?如何保证信息安全? 3如何规划安排每天工作,以及如何进行成果验收? ......
作为一个程序员,内存和磁盘的这些事情,你不得不知道啊!!!
截止目前,我已经分享了如下几篇文章: 一个程序在计算机中是如何运行的?超级干货!!! 作为一个程序员,CPU的这些硬核知识你必须会! 作为一个程序员,内存的这些硬核知识你必须懂! 这些知识可以说是我们之前都不太重视的基础知识,可能大家在上大学的时候都学习过了,但是嘞,当时由于老师讲解的没那么有趣,又加上这些知识本身就比较枯燥,所以嘞,大家当初几乎等于没学。 再说啦,学习这些,也看不出来有什么用啊!
别低估自己的直觉,也别高估自己的智商
所有群全部吵翻天,朋友圈全部沦陷,公众号疯狂转发。这两周没怎么发原创,只发新闻,可能有人注意到了。我不是懒,是文章写了却没发,因为大家的关注力始终在这次的疫情上面,发了也没人看。当然,我...
这个世界上人真的分三六九等,你信吗?
偶然间,在知乎上看到一个问题 一时间,勾起了我深深的回忆。 以前在厂里打过两次工,做过家教,干过辅导班,做过中介。零下几度的晚上,贴过广告,满脸、满手地长冻疮。   再回首那段岁月,虽然苦,但让我学会了坚持和忍耐。让我明白了,在这个世界上,无论环境多么的恶劣,只要心存希望,星星之火,亦可燎原。   下文是原回答,希望能对你能有所启发。   如果我说,这个世界上人真的分三六九等,
为什么听过很多道理,依然过不好这一生?
记录学习笔记是一个重要的习惯,不希望学习过的东西成为过眼云烟。做总结的同时也是一次复盘思考的过程。 本文是根据阅读得到 App上《万维钢·精英日课》部分文章后所做的一点笔记和思考。学习是一个系统的过程,思维模型的建立需要相对完整的学习和思考过程。以下观点是在碎片化阅读后总结的一点心得总结。
B 站上有哪些很好的学习资源?
哇说起B站,在小九眼里就是宝藏般的存在,放年假宅在家时一天刷6、7个小时不在话下,更别提今年的跨年晚会,我简直是跪着看完的!! 最早大家聚在在B站是为了追番,再后来我在上面刷欧美新歌和漂亮小姐姐的舞蹈视频,最近两年我和周围的朋友们已经把B站当作学习教室了,而且学习成本还免费,真是个励志的好平台ヽ(.◕ฺˇд ˇ◕ฺ;)ノ 下面我们就来盘点一下B站上优质的学习资源: 综合类 Oeasy: 综合
如何优雅地打印一个Java对象?
你好呀,我是沉默王二,一个和黄家驹一样身高,和刘德华一样颜值的程序员。虽然已经写了十多年的 Java 代码,但仍然觉得自己是个菜鸟(请允许我惭愧一下)。 在一个月黑风高的夜晚,我思前想后,觉得再也不能这么蹉跎下去了。于是痛下决心,准备通过输出的方式倒逼输入,以此来修炼自己的内功,从而进阶成为一名真正意义上的大神。与此同时,希望这些文章能够帮助到更多的读者,让大家在学习的路上不再寂寞、空虚和冷。 ...
雷火神山直播超两亿,Web播放器事件监听是怎么实现的?
Web播放器解决了在手机浏览器和PC浏览器上播放音视频数据的问题,让视音频内容可以不依赖用户安装App,就能进行播放以及在社交平台进行传播。在视频业务大数据平台中,播放数据的统计分析非常重要,所以Web播放器在使用过程中,需要对其内部的数据进行收集并上报至服务端,此时,就需要对发生在其内部的一些播放行为进行事件监听。 那么Web播放器事件监听是怎么实现的呢? 01 监听事件明细表 名
3万字总结,Mysql优化之精髓
本文知识点较多,篇幅较长,请耐心学习 MySQL已经成为时下关系型数据库产品的中坚力量,备受互联网大厂的青睐,出门面试想进BAT,想拿高工资,不会点MySQL优化知识,拿offer的成功率会大大下降。 为什么要优化 系统的吞吐量瓶颈往往出现在数据库的访问速度上 随着应用程序的运行,数据库的中的数据会越来越多,处理时间会相应变慢 数据是存放在磁盘上的,读写速度无法和内存相比 如何优化 设计
Linux 命令(122)—— watch 命令
1.命令简介 2.命令格式 3.选项说明 4.常用示例 参考文献 [1] watch(1) manual
Linux 命令(121)—— cal 命令
1.命令简介 2.命令格式 3.选项说明 4.常用示例 参考文献 [1] cal(1) manual
记jsp+servlet+jdbc实现的新闻管理系统
1.工具:eclipse+SQLyog 2.介绍:实现的内容就是显示新闻的基本信息,然后一个增删改查的操作。 3.数据库表设计 列名 中文名称 数据类型 长度 非空 newsId 文章ID int 11 √ newsTitle 文章标题 varchar 20 √ newsContent 文章内容 text newsStatus 是否审核 varchar 10 news...
Python新型冠状病毒疫情数据自动爬取+统计+发送报告+数据屏幕(三)发送篇
今天介绍的项目是使用 Itchat 发送统计报告 项目功能设计: 定时爬取疫情数据存入Mysql 进行数据分析制作疫情报告 使用itchat给亲人朋友发送分析报告(本文) 基于Django做数据屏幕 使用Tableau做数据分析 来看看最终效果 目前已经完成,预计2月12日前更新 使用 itchat 发送数据统计报告 itchat 是一个基于 web微信的一个框架,但微信官方并不允
相关热词 c# 时间比天数 c# oracle查询 c# 主动推送 事件 c# java 属性 c# 控制台 窗体 c# 静态类存值 c#矢量作图 c#窗体调用外部程式 c# enum是否合法 c# 如何卸载引用
立即提问