spring mvc中controller怎么传递参数到jsp页面中的java代码块

试了一下在返回值是String的方法

request.setAttribute("...", object);

没用
再试了下void方法使用request, response

request.setAttribute(("...", object);
request.getRequestDispatcher("...").forward(request, response);

也没用

2个回答

你是设置在request中的,试试放在Session中用Session的getAttribute来获取看看。
或者使用全局静态变量存储,jsp页面再使用。

我这样是可以的

@Controller
@RequestMapping(value="bookModule")
public class BookModuleController {
    @RequestMapping(value="/viewBooklist")
    public String viewBooklist(Integer id, HttpServletRequest request) {
        request.setAttribute("id", id);
        return "/viewBooklist";
    }
}

另外也可以用ModelAndView

-----------------------------分割线

controller

package net.linxingyang.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping(value="test")
public class TestController {

    @RequestMapping(value="/index")
    public String viewBooklist(Integer id, HttpServletRequest request) {
        System.out.println("id=" + id);
        request.setAttribute("id", id);
        return "/index";
    }
}

index.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<body>
first --> ${id }<br/><br/>
second --> 
<% 
    Integer id = (Integer)request.getAttribute("id");
    out.write("id=" + id);
%>
</body>
</html>

结果

图片说明

JKL852qaz
林兴洋 jsp中 <% %> 这里面的java代码块 能获取
大约一年之前 回复
JKL852qaz
林兴洋 记得没错的话,jstl标签最后还是解析成的<%%>
大约一年之前 回复
konosuba
konosuba 谢谢,不过我是指jsp中 <% %> 这里面的java代码块,这样不是只能${}这样用吗,我想在java代码块中做一点处理
大约一年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
spring mvc错误 大神们帮帮忙

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'systemPropertiesModeName' threw exception; nested exception is org.springframework.core.ConstantException: Field 'SYSTEM_PROPERTIES_MODE_ENVIRONMENT' not found in class [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1361) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:626) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) at javax.servlet.GenericServlet.init(GenericServlet.java:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4659) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445) at org.apache.catalina.core.StandardService.start(StandardService.java:519) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:581) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'systemPropertiesModeName' threw exception; nested exception is org.springframework.core.ConstantException: Field 'SYSTEM_PROPERTIES_MODE_ENVIRONMENT' not found in class [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer] at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1358) ... 41 more 2014-9-27 15:41:35 org.apache.catalina.core.ApplicationContext log 严重: StandardWrapper.Throwable org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'systemPropertiesModeName' threw exception; nested exception is org.springframework.core.ConstantException: Field 'SYSTEM_PROPERTIES_MODE_ENVIRONMENT' not found in class [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1361) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:626) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) at javax.servlet.GenericServlet.init(GenericServlet.java:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4659) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445) at org.apache.catalina.core.StandardService.start(StandardService.java:519) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:581) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'systemPropertiesModeName' threw exception; nested exception is org.springframework.core.ConstantException: Field 'SYSTEM_PROPERTIES_MODE_ENVIRONMENT' not found in class [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer] at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1358) ... 41 more 2014-9-27 15:41:35 org.apache.catalina.core.StandardContext loadOnStartup 严重: Servlet /JiaGuManages threw load() exception org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are: PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'systemPropertiesModeName' threw exception; nested exception is org.springframework.core.ConstantException: Field 'SYSTEM_PROPERTIES_MODE_ENVIRONMENT' not found in class [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer] at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1127) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:900) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1358) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:626) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) at javax.servlet.GenericServlet.init(GenericServlet.jav a:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4659) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445) at org.apache.catalina.core.StandardService.start(StandardService.java:519) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:581) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: org.springframework.core.ConstantException: Field 'SYSTEM_PROPERTIES_MODE_ENVIRONMENT' not found in class [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer] at org.springframework.core.Constants.asObject(Constants.java:144) at org.springframework.core.Constants.asNumber(Constants.java:112) at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.setSystemPropertiesModeName(PropertyPlaceholderConfigurer.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1114)

Spring WebFlux Body请求的内容丢失

公司项目需要用Spring WebFlux搭建了一个响应式的Web应用,但发现当Body请求的内容过大(比如2K左右),多发起几次请求后端接收会丢失数据,甚至报错,如下所示: reactor.core.Exceptions$ErrorCallbackNotImplemented: org.springframework.web.server.ServerWebInputException: Response status 400 with reason "Request body is missing: reactor.core.publisher.Mono<org.xiaobao.reactor4bodytest.dto.RespErrMsg> org.xiaobao.reactor4bodytest.controller.APIController.test1(reactor.core.publisher.Mono<java.lang.String>)" 难不成Spring的这个响应式框架本身的问题,求各位大神帮助。(我本地有个简化版的工程,email和qq都可以)

SSM+Shiro项目spring依赖注入出错

求大神们看一下!!! 配置一个SSM+Shiro的项目时,启动时报错: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shiroFilter' defined in class path resource [spring-shiro.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot resolve reference to bean 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0' while setting bean property 'transactionAttributeSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor#0' defined in class path resource [spring-shiro.xml]: Cannot resolve reference to bean 'securityManager' while setting bean property 'securityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityManager' defined in class path resource [spring-shiro.xml]: Cannot resolve reference to bean 'userRealm' while setting bean property 'realm'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userRealm': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: **Bean named 'userService' is expected to be of type 'com.***.***.service.UserService' but was actually of type 'com.sun.proxy.$Proxy21'** Spring配置如下: spring-config.xml(applicationContext.xml): ``` <?xml version="1.0" encoding="UTF-8"?> <!-- applicationContext --> <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <aop:aspectj-autoproxy/> <!-- 配置文件注入 --> <context:property-placeholder location="classpath:config.properties"/> <context:component-scan base-package="com.***.***"/> <bean class="com.mzj.im.util.SpringUtils"/> <import resource="classpath:spring-mybatis.xml"/> <import resource="classpath:spring-shiro.xml"/> </beans> ``` spring-shiro.xml: ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <import resource="classpath:spring-cache.xml"/> <!-- 缓存管理器 --> <bean id="cacheManager" class="com.***.***.util.SpringCacheManagerWrapper"> <property name="cacheManager" ref="springCacheManager"/> </bean> <!-- 项目自定义的Realm --> <bean id="userRealm" class="com.***.***.web.filter.shiro.UserRealm"> <property name="credentialsMatcher" ref="credentialsMatcher"/> <property name="cachingEnabled" value="false"/> </bean> <!-- 安全管理器 --> <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"> <property name="realm" ref="userRealm"/> <property name="sessionManager" ref="sessionManager"/> <property name="cacheManager" ref="cacheManager"/> <property name="rememberMeManager" ref="rememberMeManager"/> </bean> ........................... <!-- 开启Shiro注解的Spring配置方式的beans。在lifecycleBeanPostProcessor之后运行 --> <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor"/> <bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor"> <property name="securityManager" ref="securityManager"/> </bean> <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/> </beans> ``` spring-mvc.xml: ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <aop:aspectj-autoproxy proxy-target-class="true"/> <!-- 自动扫描web包下的所有类,包含spring mvc的控制器、控制器增强及aop控制 --> <context:component-scan base-package="com.***.***.web.controller"/> <!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 --> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/> <!-- 该写法无法注入webSocket--> <mvc:annotation-driven/> <!-- 当在web.xml中DispatcherServlet使用<url-pattern>/</url-pattern>映射时,能映射静态资源 --> <mvc:default-servlet-handler/> <!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/view/" p:suffix=".html"/> <!-- todo: 默认视图解析器--> <!-- 默认的视图解析器 在上边的解析错误时使用 (默认使用html)- --> <bean id="defaultViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:order="1"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="contentType" value="text/html"/> <property name="prefix" value="/WEB-INF/view"/> <property name="suffix" value=".html"/> </bean> </beans> ``` 目录结构: ![图片说明](https://img-ask.csdn.net/upload/201702/06/1486351993_557780.png) 求助,求助

jsp+servlet实现分页

我在做jsp+servlet数据分页的时候,无法实现前后翻页, 下面是我的分层结构 jsp [code="java"] <%@page contentType="text/html;charset=gbk" %> <%@page language="java" import="java.util.*" %> <%@ include file="inc/cmnAuthenticate.jsp" %> <%@page language="java" import="ch05.*" %> <% Vector vMails = null; int totalPage=0; int curPage=0; int countPerPage=10; int pageNumber=1; Hashtable myValues = (Hashtable)session.getAttribute(CommonConst.VIEWID_INBOXLIST); if ( myValues != null ) { vMails = (Vector)myValues.get("mails"); if ( vMails == null ) { vMails = new Vector(); } if(myValues.get("totalPage")!=null){ totalPage=((Integer)myValues.get("totalPage")).intValue(); } if(myValues.get("curPage")!=null){ curPage=((Integer)myValues.get("curPage")).intValue(); } } %> <html> <head> <title>收件箱</title> <meta http-equiv="Content-Type" content="text/html; charset=gbk"> <script language="JAVASCRIPT" src="common\cmnScript.js"></script> <script language="JAVASCRIPT" src="inbox.js"></script> <link rel="stylesheet" type="text/css" href="common\cmnStyle.css" TITLE="common"></link> <script language="JAVASCRIPT"> <% if ( session.getAttribute("errMsg") != null ) { %> var sErrMsg = "<%=session.getAttribute("errMsg")%>"; <% } else { %> var sErrMsg = ""; <% } %> </script> </head> <%@ include file="inc/cmnPagePart1.jsp" %> <table border=0 cellpadding=0 cellspacing=0 width=650 align=center> <tr> <td height=15>&nbsp;</td> </tr> <tr> <td height=30>你当前共有 <font color=blue><%=vMails.size()%></font> 封邮件。</td> </tr> <tr> <td> <table border=1 bordercolor="#13A7FD" cellpadding=2 cellspacing=0 width=650 align=center> <tr> <td width=130> <b>发件人</b> </td> <td width=400> <b>主题</b> </td> <td width=120> <b>发信时间</b> </td> </tr> <% if ( vMails.size() > 0 ) { for ( int i=0; i<vMails.size(); i++ ) { if(i<countPerPage){ MailContent mailContent = (MailContent)vMails.get(i); String sFrom = mailContent.getSender(); String sSubject = mailContent.getSubject(); String sSendTime = mailContent.getSendTime(); String sReadFlg = mailContent.getReadFlg(); if ( sReadFlg.equals("0") ) { %> <tr> <td> <b><%=sFrom%></b> </td> <td> <b><a href="javascript:gotoMail('<%=i%>')"><%=sSubject%></a></b> </td> <td> <%=sSendTime%> </td> </tr> <% } else { %> <tr> <td> <%=sFrom%> </td> <td> <a href="javascript:gotoMail('<%=i%>')"><%=sSubject%></a> </td> <td> <%=sSendTime%> </td> </tr> <% } } } } else { %> <tr> <td colspan=3> 没有任何邮件! </td> </tr> <% } %> </table> </td> </tr> <tr> <td height=20>&nbsp;</td> </tr> </table> <form name="form_main" action="servlet/Inbox" method="post" > <input type="hidden" name="mailIndex" value=""> <div align="right"> 共 <font color=blue><%=totalPage%></font> 页,当前是第 <font color=blue><%=(totalPage==0?0:curPage+1)%></font> 页 &nbsp; <% if ( curPage > 0 ) { %> <a href="javascript: gotoPagePosition('0')">首页</a> &nbsp; <a href="javascript: gotoPagePosition('<%=curPage-1%>')">前一页</a> &nbsp; <% } else { %> &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <% } if ( curPage < totalPage-1 ) { %> <a href="javascript: gotoPagePosition('<%=curPage+1%>')">后一页</a> &nbsp; <a href="javascript: gotoPagePosition('<%=totalPage-1%>')">末页</a> &nbsp; <% } else { %> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <% } %> <input type="hidden" name="pageId" value="S0101"> <input type="hidden" name="gotoPageNo" value=""> </div> </form> <%@ include file="inc/cmnPagePart2.jsp" %> [/code] servlet [code="java"]/* * This product includes software developed by the * Apache Software Foundation (http://www.apache.org/). */ package ch05.controller; import java.io.*; import java.util.Hashtable; import javax.servlet.*; import javax.servlet.http.*; import ch05.*; import ch05.module.*; /** * 针对收件箱页面的Servlet * @author Administrator * @version 1.0 */ public class Inbox extends HttpServlet implements java.io.Serializable { /** * */ private static final long serialVersionUID = 1L; public void doGet ( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { //设置提交表单的中文编码 request.setCharacterEncoding("GBK"); HttpSession mySession = request.getSession(true); //清空错误消息 mySession.setAttribute("errMsg",""); //是否非法进入本页面 if ( mySession.getAttribute("username") == null ) { response.sendRedirect("/ch05/login.jsp"); return; } //是否进入默认页面 if ( !request.getParameterNames().hasMoreElements() ) { //设置session中的页面值域 mySession.setAttribute(CommonConst.VIEWID_INBOXLIST, new Hashtable() ); //取得最新邮件 MInbox mInbox = new MInbox(); boolean bGetResult = mInbox.getNewestMail( mySession ); String sGotoPage = request.getParameter("gotoPageNo"); Hashtable myValues = (Hashtable)mySession.getAttribute(ch05.CommonConst.VIEWID_INBOXLIST); myValues.put( "curPage", new Integer(sGotoPage) ); mySession.setAttribute("curPage","inbox"); response.sendRedirect("/ch05/inbox.jsp"); return; } //得到用户输入信息 String sMailIndex = request.getParameter("mailIndex"); String sMailOption = request.getParameter("mailOption"); //如果用户是提交表单 if ( sMailIndex != null && sMailIndex.length() > 0 ) { //设置session中的详细页面值域 mySession.setAttribute(CommonConst.VIEWID_INBOXDETAIL, new Hashtable() ); //获得对应的邮件信息 MInbox mInbox = new MInbox(); boolean bGetResult = mInbox.getDetailMail( mySession, sMailIndex ); if ( bGetResult ) { response.sendRedirect("/ch05/inboxDetail.jsp"); } else { response.sendRedirect("/ch05/inbox.jsp"); } } //如果用户是从详细页面迁移过来的 else if ( sMailOption != null && sMailOption.length() > 0 ) { String sSender = request.getParameter("sender"); String sSendTime = request.getParameter("sendTime"); String sSubject = request.getParameter("subject"); String sContent = request.getParameter("content"); //删除邮件 if ( sMailOption.equals("delete") ) { MInbox mInbox = new MInbox(); boolean bDeleteResult = mInbox.deleteMail( mySession, sSender, sSendTime ); mInbox.getNewestMail( mySession ); response.sendRedirect("/ch05/inbox.jsp"); return; } //回复邮件 else if ( sMailOption.equals("reply") ) { //设置session中的写邮件页面值域 mySession.setAttribute(CommonConst.VIEWID_SENDBOXDETAIL, new Hashtable() ); MInbox mInbox = new MInbox(); boolean bReplyResult = mInbox.replyMail( mySession, sSender, sSubject, sContent ); mySession.setAttribute("curPage","composite"); response.sendRedirect("/ch05/composite.jsp"); return; } try { MInbox mInbox=new MInbox(); mInbox.gotoPage(request, response); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } //如果用户非法进入这个页面 else { response.sendRedirect("/ch05/login.jsp"); } } public void doPost ( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { doGet( request, response ); } }[/code] 数据库处理 [code="java"]/* * This product includes software developed by the * Apache Software Foundation (http://www.apache.org/). */ package ch05.module; import java.sql.*; import java.util.*; import java.text.*; import javax.mail.*; import javax.mail.internet.*; import javax.servlet.http.*; import ch05.*; /** * 针对收件箱页面的后台处理类 * @author Administrator * @version 1.0 */ public class MInbox { public boolean getNewestMail ( HttpSession mySession ) { //设置用户信息用 Hashtable myValues = (Hashtable)mySession.getAttribute(CommonConst.VIEWID_INBOXLIST); String sHost = ""; String sUser = ""; String sPass = ""; //尝试查找用户邮箱设置 try { //载入SQLServer的JDBC驱动类 Class.forName(CommonConst.DB_DRIVER_CLASSNAME); //获得数据库连接 Connection conn = DriverManager.getConnection( CommonConst.DB_CONN_STRING ); Statement stmt = null; ResultSet rs = null; String sUsername = (String)mySession.getAttribute("username"); try { //设置数据库的rollback点 conn.setAutoCommit(false); //检查数据库中是否已经有该用户的邮箱设置 stmt = conn.createStatement(); //执行SQL语句 String sQuery = "select * from mail_setting where username='" + sUsername + "'"; rs = stmt.executeQuery( sQuery ); if (rs.next() ) { sHost = rs.getString(2); sUser = rs.getString(3); sPass = rs.getString(4); } else { mySession.setAttribute("errMsg","请首先进行邮箱设置!"); return false; } //尝试连接Pop3服务器 Properties props = System.getProperties(); Session session = Session.getDefaultInstance(props, null); //获得收件箱 Store store = session.getStore("pop3"); store.connect( sHost, sUser, sPass); //获得Folder,并按照只读打开 Folder folder = store.getFolder( "INBOX" ); folder.open( Folder.READ_WRITE ); //获得所有邮件,并依次获取内容 Message messages[] = folder.getMessages(); //往数据库中登录 for ( int i=0; i<messages.length; i++ ) { //只要不是html格式,大概没有乱码问题。。。 String sFrom = MailContent.getFrom( messages[i].getFrom()[0].toString() ); String sTo = MailContent.getFrom( messages[i].getRecipients( Message.RecipientType.TO )[0].toString() ); String sDate = (new SimpleDateFormat("yyyy/MM/dd HH:mm:ss")).format(messages[i].getSentDate()); String sSubject = messages[i].getSubject(); String sContent = ""; //如果纯文本邮件内容 if ( messages[i].getContent() instanceof String ) { sContent = (String) messages[i].getContent(); } //如果HTML格式邮件内容 else { sContent = ((MimeMultipart)messages[i].getContent()).getBodyPart(0).getContent().toString(); } //插入数据库 String sUpdateQuery = "insert into inbox values('" + sUsername + "', '" + sFrom + "', '" + sTo + "', '" + sDate + "', '" + sSubject + "', '" + sContent + "', '0') "; stmt.executeUpdate( sUpdateQuery ); } conn.commit(); conn.setAutoCommit(true); //删除服务器上的邮件 for ( int i=0; i<messages.length; i++ ) { messages[i].setFlag( Flags.Flag.DELETED, true ); } folder.close(true); store.close(); //重新获取数据库中的所有邮件,并表示在页面上 Vector vMails = new Vector(); sQuery = "select * from inbox where username='" + sUsername + "' order by send_time desc"; rs = stmt.executeQuery( sQuery ); while ( rs.next() ) { String sFrom = rs.getString(2); String sTo = rs.getString(3); String sDate = rs.getString(4); String sSubject = rs.getString(5); String sContent = rs.getString(6); String sReadFlg = rs.getString(7); MailContent mc = new MailContent(); mc.setSender(sFrom); mc.setReceiver(sTo); mc.setSendTime(sDate); mc.setSubject(sSubject); mc.setContent(sContent); mc.setReadFlg(sReadFlg); vMails.add( mc ); } myValues.put( "mails", vMails ); //计算总页数 int countPerPage=10; int totalMail=vMails.size(); int totalPage=0; if(totalMail%countPerPage==0){ totalPage=totalMail/countPerPage; } else{ totalPage=totalMail/countPerPage+1; } int curPage=0; myValues.put("curPage", new Integer(curPage)); myValues.put("totalPage", new Integer(totalPage)); } catch(Exception e) { e.printStackTrace(); mySession.setAttribute("errMsg","查找邮件时出现错误!"); return false; } finally { try { rs.close(); stmt.close(); }catch(Exception ex) { } } }catch(Exception ex) { ex.printStackTrace(); mySession.setAttribute("errMsg","查找邮件时出现错误!"); return false; } return true; } } }[/code] js [code="java"]window.onload = windowLoad; //--------------------------------- //页面载入时调用 function windowLoad() { cmnWindowLoad(); } //查看具体邮件 function gotoMail( index ) { form_main.mailIndex.value = index; form_main.submit(); } //前后翻页 function gotoPagePosition( gotoCount ) { form_main.pageId.value = "goto"; form_main.gotoPageNo.value = gotoCount; form_main.submit(); }[/code]

用spring整合xfire时传递自定义类型的对象时报空指针错误

Exception in thread "main" org.codehaus.xfire.fault.XFireFault: Fault: java.lang.NullPointerException at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89) at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:83) at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114) at org.codehaus.xfire.client.Client.invoke(Client.java:336) at org.codehaus.xfire.client.Client.invoke(Client.java:368) at test.WebServiceClientTest.testClient(WebServiceClientTest.java:43) at test.WebServiceClientTest.main(WebServiceClientTest.java:26) Caused by: java.lang.NullPointerException at org.codehaus.xfire.aegis.type.basic.ObjectType.writeObject(ObjectType.java:192) at org.codehaus.xfire.aegis.AegisBindingProvider.writeParameter(AegisBindingProvider.java:229) at org.codehaus.xfire.service.binding.AbstractBinding.writeParameter(AbstractBinding.java:273) at org.codehaus.xfire.service.binding.WrappedBinding.writeMessage(WrappedBinding.java:90) at org.codehaus.xfire.soap.SoapSerializer.writeMessage(SoapSerializer.java:80) at org.codehaus.xfire.transport.http.HttpChannel.writeWithoutAttachments(HttpChannel.java:56) at org.codehaus.xfire.transport.http.CommonsHttpMessageSender.getByteArrayRequestEntity(CommonsHttpMessageSender.java:422) at org.codehaus.xfire.transport.http.CommonsHttpMessageSender.send(CommonsHttpMessageSender.java:360) at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:123) at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48) at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26) at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131) at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79) ... 5 more

maven引入jsp-api的jar包问题,谢谢

![图片说明](https://img-ask.csdn.net/upload/201611/09/1478627853_289756.png) ![图片说明](https://img-ask.csdn.net/upload/201611/09/1478627863_160370.png) 我想知道,我没有引入jsp-api-2.0.jar这个jsp标签库的jar包,新创建一个xxx.jsp之后,为什么没有报错?

idea中的jsp文件按空格自动提示多尖括号,只是jsp的文件?

``` <input type="submit" value="提交"> <<input type="text">> <<a href=""></a> <![图片说明](https://img-ask.csdn.net/upload/201810/21/1540087832_949662.jpg) <form action=""></form> ```

spring tool suite打开不了,会报下面的错误

已经改动了sts.ini中的配置,还是会报错

spring-mybatis.xml而配置druid连接池错误

package gg; public class hj { <?xml version=\"1.0\" encoding=\"UTF-8\"?> <beans xmlns=\"http://www.springframework.org/schema/beans\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:context=\"http://www.springframework.org/schema/context\" xmlns:tx=\"http://www.springframework.org/schema/tx\" xmlns:aop=\"http://www.springframework.org/schema/aop\" xsi:schemaLocation=\"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd \"> <!--自动扫描--> <context:component-scan base-package=\"com.books\"> <context:exclude-filter type=\"annotation\" expression=\"org.springframework.stereotype.Controller\"/> </context:component-scan> <context:property-placeholder ignore-unresolvable=\"true\" location=\"classpath:jdbc.properties\"/> <!--============================配置数据源=================================--> <bean id=\"dataSource\" class=\"com.alibaba.druid.pool.DruidDataSource\" init-method=\"init\" destroy-method=\"close\"> <property name=\"driverClassName\" value=\"${driverClass}\"/> <property name=\"url\" value=\"${jdbcurl}\"/> <property name=\"username\" value=\"${jdbcusername}\"/> <property name=\"password\" value=\"${jdbcpassword}\"/> <!-- 初始化连接大小 --> <property name=\"initialSize\" value=\"2\"/> <!-- 连接池最大使用连接数量 --> <property name=\"maxActive\" value=\"${maxActive}\"/> <!-- 连接池最大空闲 --> <!-- <property name=\"maxIdle\" value=\"20\" /> --> <!-- 连接池最小空闲 --> <property name=\"minIdle\" value=\"${minIdle}\"/> <!-- 获取连接最大等待时间 --> <property name=\"maxWait\" value=\"${maxWait}\"/> <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 --> <property name=\"timeBetweenEvictionRunsMillis\" value=\"60000\"/> <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 --> <property name=\"minEvictableIdleTimeMillis\" value=\"25200000\"/> <!-- 打开removeAbandoned功能 --> <property name=\"removeAbandoned\" value=\"true\"/> <!-- 1800秒,也就是30分钟 --> <property name=\"removeAbandonedTimeout\" value=\"1800\"/> <!-- 关闭abanded连接时输出错误日志 --> <property name=\"logAbandoned\" value=\"true\"/> <!-- 监控数据库 --> <!-- <property name=\"filters\" value=\"stat\" /> --> <property name=\"filters\" value=\"mergeStat\"/> </bean> <!-- mybatis和spring完美整合,不需要mybatis的配置映射文件 --> <bean id=\"sqlSessionFactory\" class=\"org.mybatis.spring.SqlSessionFactoryBean\"> <property name=\"dataSource\" ref=\"dataSource\"/> <!-- 自动扫描mapping.xml文件 --> <property name=\"mapperLocations\" value=\"classpath:/mapper/*.xml\"/> <!-- 分页查询(mybatis 3.2.8以上版本)-张晗 --> <property name=\"plugins\"> <array> <bean class=\"com.github.pagehelper.PageInterceptor\"> <property name=\"properties\"> <value> helperDialect=mysql </value> </property> </bean> </array> </property> </bean> <!--DAO接口所在包名,Spring会自动查找其下的类--> <bean class=\"org.mybatis.spring.mapper.MapperScannerConfigurer\"> <!--制定扫描的包名扫描dao层下的类--> <property name=\"basePackage\" value=\"com.books.dao\"/> <property name=\"sqlSessionFactoryBeanName\" value=\"sqlSessionFactory\"/> </bean> <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx --> <bean id=\"transactionManager\" class=\"org.springframework.jdbc.datasource.DataSourceTransactionManager\"> <property name=\"dataSource\" ref=\"dataSource\"/> </bean> <!--使用注释事务 --> <tx:annotation-driven transaction-manager=\"transactionManager\"/> <!-- <import resource=\"spring-schedule.xml\"/> --> </beans> 15-Mar-2018 16:01:27.914 严重 [RMI TCP Connection(5)-127.0.0.1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [spring-mybatis.xml]: Invocation of init method failed; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

Gradle构建的JavsWeb应用,如何在代码中获取build.gradle的version

如题。需求要求在登录页面显示web项目的版本号。 百度了很久没找到类似的问题,所以就来提问了~ build.gradle里面 ``` group = 'Tomcat_Server' version = '0.6.0-Debug' sourceCompatibility = 1.8 ``` 想要在java代码(Controller层)中获取到“0.6.0-Debug”这个东西

jsp项目传到服务器后 servlet访问不到

Object not found! The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. If you think this is a server error, please contact the webmaster. 我是把项目打包成war包上传的 提交表单到这个servlet,然后出现这个,求大神告知解决方法

spring 5.0 log4j Log4jConfigListener配置项问题

为什么使用spring 5.0配置Log4jConfigListener时报红呢?版本调到4就行,5做什么调整了么? ![图片说明](https://img-ask.csdn.net/upload/201711/06/1509981576_7127.png) ![图片说明](https://img-ask.csdn.net/upload/201711/06/1509981592_472355.png) ![图片说明](https://img-ask.csdn.net/upload/201711/06/1509981603_171304.png) ![图片说明](https://img-ask.csdn.net/upload/201711/06/1509981677_356560.png) ![图片说明](https://img-ask.csdn.net/upload/201711/06/1509981690_482233.png)

JAV连接数据库找不到数据库驱动程序

以下是代码 package dbConnection; import java.sql.*; public class JDBCConnection { public Connection connection; public static void main(String[] args) { JDBCConnection dc=new JDBCConnection(); dc.close(); } public JDBCConnection(){ try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); System.out.println("正在建立数据库连接。。。"); connection=DriverManager.getConnection("jdbc:odbc:DSAccess"); System.out.println("数据库连接成功"); } catch(ClassNotFoundException ex){ System.out.println("找不到数据库驱动程序"); } catch(SQLException ex){ System.out.println("不能建立与数据库的连接"); } } public void close(){ try{ System.out.println("正在关闭数据库连接。。。"); connection.close(); System.out.println("数据库连接关闭成功"); } catch(Exception e){ System.out.println("数据库连接关闭失败"); } } } 运行显示不能连接到数据库,哪位大神能帮我看看哪里出了问题

spring boot和mybatis整合项目,测试的时候出现这个错误,哪位大神知道怎么解决

# 在持久层测试运行的时候出现以下错误,一直找不出什么原因 ``` org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driver at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:587) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1250) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:541) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:138) [spring-boot-test-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12] at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12] at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12] at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12] at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12] at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) [.cp/:na] at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) [.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538) [.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) [.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) [.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206) [.cp/:na] Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driver at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] ... 42 common frames omitted Caused by: java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driver at org.springframework.util.Assert.state(Assert.java:94) ~[spring-core-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:224) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.initializeDataSourceBuilder(DataSourceProperties.java:176) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration.createDataSource(DataSourceConfiguration.java:43) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari.dataSource(DataSourceConfiguration.java:81) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_171] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_171] at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_171] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] ... 43 common frames omitted ```

学习SSM框架分页插件查询时出现空指针异常,求解!!!

异常代码: ``` java.lang.NullPointerException at com.atguigu.crud.test.MvcTest.testPage(MvcTest.java:53) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209) ``` 测试了一下: ``` MvcResult result = mockMvc.perform(MockMvcRequestBuilders.get("/emps").param("pn", "1")).andReturn(); MockHttpServletRequest request = result.getRequest(); System.out.println("1:"+request); System.out.println("2:"+request.getAttribute("pageInfo")); ``` 结果: 1:org.springframework.mock.web.MockHttpServletRequest@4a067c25 2:null 是在执行了getAttribute()这个方法后出现的异常 代码检查了几遍了,不知道是不是哪个配置文件出了问题。

JAV求代码,实现连接数据库,并执行写在XML中的SQL

最好详细一点,新手小白。 就是按照需求,以后修改SQL都再配置文件中修改而不修改代码。

Springboot的单元测试异常:SqlSessionTemplate

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.mybatis.spring.SqlSessionTemplate]: Factory method 'sqlSessionTemplate' threw exception; nested exception is java.lang.NullPointerException at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1181) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1075) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1350) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.popul

jav怎么设置环境,我加设置页游

我用jav怎么设置呢????请告诉我好几个人也有这个问题,你们呢我不知道再说吧!gg

在常见的服务器环境中使用Spring和php的优点

<div class="post-text" itemprop="text"> <p>What I would propose would probably sound strange, but I have my reasons for it. </p> <p>For a long time, we've had this Spring based API, which originated as an abstract set of REST services for CRUD functionality. With time however, we started building business and presentation layers on top until we reached a state of a dead end. Do not get me wrong, Spring/Hibernate are great frameworks, and being built on top of the JVM has its definite advantages, including performance over other web technologies, such as PHP. Compared to PHP, it gives us a much deeper way of controlling aspects such as transactioning, multithreading, dealing with byte data, control over native C++ applications, using JNI, etc.</p> <p>Where the stack clearly hits a hard wall, is where the requirements get changed most often, namely the business and presentation layers. Turning the applciation into a modern, user-centered social applciation, we've experienced the toughest challenge in out careers. Java EE presentation technologies are tough to work with. Also, changing the business requirements became a tremendously long cycling because of the traditional hurdles in building testing and deploying massive Java applications.</p> <p>It also felt like for a large part, we are trying to reinvent the wheel. In the PHP world, so many projects exist already, which give you a complete management system, agnostic to any kind of backend system (mapping hooks to REST/SOAP endpoints) . Many of them have all these functionalities ready, allow for admin-friendly change of scenarious, and rules, have templating, etc. Plus, being PHP based means absolutely no time wasted in building and deploying. Write the change, test, asert that it works, and switch. </p> <p>Our idea now is to find a way to move the business and presentation layers in such a kind of front-server PHP-based application, and leave the pure backend stuff to Spring/Hibernate. We have a few concerns though, coming from our relative inexperience with Spring.</p> <ol> <li><p>If we implement the business methods using PHP methods, how do we keep transactional security? I mean if a business method has to make three separate HTTP requests to the JAVA, how can we guarantee that they will all be executed in the same transaction, DB-wise?</p></li> <li><p>Is there a way to use proxies or promise objects between both systems? For instance, if the PHP business method needs to call a Spring search method get a collection of objects from the database, and then pass it on to another spring method, this will mean that teh whole collection will have to be sent back and forth. Perhaps, one could store it in a session object on the JAVA side, and simply sent an empty proxy back to the frontend, which the frontend can bass back to another jav method.</p></li> <li><p>A lot of our Spring based functionailities rely on a structure of plugins, using Spring events. How can we make so that our frontend server also gets notified on every ackend event that happens. I have two ideas here: a post-processing-filter that simply makes a POST request to a controller on the frontend server, using some naming convention. or ... using some kind of a message queue, such as JMS or RabbitMQ, or why not even something like Reddis, where one can watch data for changes</p></li> </ol> <p>Anyone who has done that before? Is this a good idea in general? Any suggestions how to resolve the aforementioned issues?</p> </div>

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

点沙成金:英特尔芯片制造全过程揭密

“亚马逊丛林里的蝴蝶扇动几下翅膀就可能引起两周后美国德州的一次飓风……” 这句人人皆知的话最初用来描述非线性系统中微小参数的变化所引起的系统极大变化。 而在更长的时间尺度内,我们所生活的这个世界就是这样一个异常复杂的非线性系统…… 水泥、穹顶、透视——关于时间与技艺的蝴蝶效应 公元前3000年,古埃及人将尼罗河中挖出的泥浆与纳特龙盐湖中的矿物盐混合,再掺入煅烧石灰石制成的石灰,由此得来了人...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

我说我不会算法,阿里把我挂了。

不说了,字节跳动也反手把我挂了。

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

你打算用Java 8一辈子都不打算升级到Java 14,真香

我们程序员应该抱着尝鲜、猎奇的心态,否则就容易固步自封,技术停滞不前。

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

一文带你入门Java Stream流,太强了

两个星期以前,就有读者强烈要求我写一篇 Java Stream 流的文章,我说市面上不是已经有很多了吗,结果你猜他怎么说:“就想看你写的啊!”你看你看,多么苍白的喜欢啊。那就“勉为其难”写一篇吧,嘻嘻。 单从“Stream”这个单词上来看,它似乎和 java.io 包下的 InputStream 和 OutputStream 有些关系。实际上呢,没毛关系。Java 8 新增的 Stream 是为...

立即提问
相关内容推荐