当TomCat启动后能不能更改Spring的数据库连接,如何改

当TomCat启动后能不能更改Spring的数据库连接,如何改?
[b]问题补充:[/b]
问题描述:
当进入系统前会有一个数据库连接选择,其中主要是改变连接的用户名和密码,但每次服务一启动,就自动加载了applicationContext.xml,不论你怎么改用户名,都只是前一次的,如何做才能达到我想要的?
[b]问题补充:[/b]
我用的是spring+jpa+flex
[b]问题补充:[/b]
手动加载spring的配置文件:
具体如何实现?
[b]问题补充:[/b]
ContextLoader contextLoader = new ContextLoader();
contextLoader.initWebApplicationContext(request.getSession().getServletContext());

找不到applicationContext.xml,它给的路径是/WEB-INF/applicationContext.xml,而我的是在/WEB-INF/classes/applicationContext.xml下的,怎样改啊?
[b]问题补充:[/b]
但是它出错啦,当刷新页面,切换数据库时:
Cannot initialize context because there is already a root application context present - check whether you have multiple ContextLoader* definitions in your web.xml

10个回答

spring把WebApplicationContext作为ServletContext的一个属性存放着,
所以你得把contextLoader 作为ServletContext的一个属性存放着
你得判断下嘛,如果存在,就不进行contextLoader.initWebApplicationContext(request.getSession().getServletContext()); ,如果要切换数据库,再就用contextLoader.closeWebApplicationContext(request.getSession().getServletContext()));
再重新contextLoader.initWebApplicationContext(request.getSession().getServletContext());

动态修改了数据库连接,除非你重新让spring加载所有bean,不然, 使用的还是之前的数据库连接

同时配置多个数据源,然后每个数据源给配置一个类似于JdbcTemplate一样的封装对象,这样如果有切换数据库的需求时,切换成不同的jdbcTemplate;这样应该可以满足需求吧?

一般都是选择了以后,还需要重新启动一次的.

那就配置一个跟JdbcTemplate地位相同的SessionFactory不就OK了吗?唯一的问题就是多启动了一个数据库而已,如果你不介意这点损失的话应该OK;要不就动态修改XML配置文件,然后重启下Spring;

那你就不要在web.xml里配置spring的加载listener或servlet,

在当进入系统前会有一个数据库连接选择之后,你手动加载spring的配置文件,就行了

参考ContextLoaderListener类里的初始化方法,就行了

不要用tomcat的连接池了,自己写一个datasource实现,用代理模式,启动的时候再把用户名口令传进去

MyDataSource implements DataSource {
private String username;
private String password;

public void setUsername(...)...
public void setPassword(...)...

public Connection getConnection() {
if (username==null || password==null)
throw new SQLException...
return DriverManager.getConnection("", "", username, password);
}
}

进入系统前会有一个数据库连接选择,改变连接的用户名和密码之后,
用dom4j去操作spring配置文件把相应的连接的用户名和密码设置到相应位置,不过最好是spring配置文件里的连接的用户名和密码是以占位符的形式,然后就只要新建一个properties文件把连接的用户名和密码写到里面就完成配置文件的修改了,

接下来,就是要用手动去加载spring的配置文件了
在servlet里调用
ContextLoader contextLoader = new ContextLoader();
contextLoader.initWebApplicationContext(request.getSession().getServletContext());

你把applicationContext.xml文件拷过去不就行了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
关于异构数据库的连接池?
我们通常讲的数据库连接池都是同一种数据库的连接比如连接同一个oracle的多个数据库连接到池里,现在有遇到有这样的需求,在一个web应用中有些表是要连接sqlite有些表是连接oracle的,具体连那个是根据读取配置文件来的,目前做法是因为数据库连接类型不是固定不变的,数据库连接时根据配置文件产生一个连接然后关闭一个连接。这种做法必然效率低下,可不可以在这种情况下用长连接或数据库连接池那。 [b]问题补充:[/b] to pan_java:问题是我这个web界面还要求管理多库这样不是要配多个数据库连接池 [b]问题补充:[/b] to pjun:你们这种方法为常不可,我现在是用spring管理多数据源,用户login进去后取出每个库里的一小部分数据放在主页面上,数据旁标上库名,用户点那个库就进入那库,一般有5到10库左右,因为设计到数据库连接的切换,所以先前就没用连接池,只是一个管理界面,没有很大用户数量。如何这样每个库都要配连接池,工作量很大的,也不太合理 [b]问题补充:[/b] 这样是不是搞复杂了 [b]问题补充:[/b] to pjun:我现在新增一个库就要修改一个配置文件,如果在tomcat配置数据源的话,每加一个库就要配一个数据源有一点工作量,而且读取数据库时代码和数据源要绑在一起,部署人员还要配置tomcat数据源这又增加了部署难度 [b]问题补充:[/b] to pjun:最后一点tomcat配置的数据源,spring可以管理吗? [b]问题补充:[/b] 已经决定那,把oracle数据库连接和sqlite连接放在一个池里,或维持长连接,这下搞复杂那,要把不同数据库的连接放在数据库里,还要区分oracle和sqlite,有这种可能吗 [b]问题补充:[/b] to pjun:我们这里的大拿也决定那,把oracle数据库连接和sqlite连接放在一个池里,或维持长连接,这下搞复杂那,要把不同数据库的连接放在连接池里,还要区分oracle和sqlite,有这种可能吗 ? oracle数据库连接和sqlite连接放在一个池里这个应该可以实现的,不过从池里拿连接要判断一下
spring+ibatis 数据库修改数据不成功的问题
工程中调用dao执行数据表修改,调用方法如下: ![图片说明](https://img-ask.csdn.net/upload/201604/25/1461574636_647109.png) sqlmap描述如下图: ![图片说明](https://img-ask.csdn.net/upload/201604/25/1461574713_220236.png) 最后编译通过,发布到tomcat后运行,浏览器显示异常,异常描述如下: ![图片说明](https://img-ask.csdn.net/upload/201604/25/1461574812_434830.png) 求大神解答这是什么情况,该如何解决?
【急】问一个关于java web中tomcat连接mysql数据库的问题(问题点数40无满意结贴
我是计科专业在做毕业设计没接触过java,做一个在线答疑系统,在csdn上下了一个jsp+struts2+spring的感觉比较全的系统,下载地址为http://download.csdn.net/detail/hmshust/6950301,该文是0积分的,下载的如图![图片说明](https://img-ask.csdn.net/upload/201505/07/1431008698_848163.png),里面css,mysql数据库文件,js脚本,java源文件。我按介绍在tomcat的lib中放入数据库连接包,我按介绍在conf下的server.xml中做了如下修改![图片说明](https://img-ask.csdn.net/upload/201505/07/1431008981_804088.png)不怎么懂这修改。我早上在运行时还能打开登录注册界面,结果注册之后就弹出的是http status 500不能继续下去了。结果晚上不知道打开什么连主页也进不去了,我不是也别懂怎么运行这个项目,真心求教只想快点通过毕设,希望好心人能告诉我具体该怎么操作,真心的,谢谢了,或者也可以加q981542238诚心请教
Springboot2.2.2不能连接数据库
1.写一个体验redis缓存的demo,不能连接数据库。 导入其他人的项目可以,连接自己的数据库,可以连接成功。确定数据库连接信息没有写错。参考网上,修改mysql-connector-java的版本也没有用。 系统环境:java-1.8; mysql-5.1.62; IDEA 2019-1.4;SpringBoot 2.2.2; 2.pom文件: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.2.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.example</groupId> <artifactId>cache</artifactId> <version>0.0.1-SNAPSHOT</version> <name>cache</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.1.1</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.34</version> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project> 3.配置文件 ![图片说明](https://img-ask.csdn.net/upload/202001/06/1578275877_830078.png) 4.报错信息 ![图片说明](https://img-ask.csdn.net/upload/202001/06/1578276565_257380.png) ![图片说明](https://img-ask.csdn.net/upload/202001/06/1578275918_258494.png) ![图片说明](https://img-ask.csdn.net/upload/202001/06/1578275931_720085.png) ![图片说明](https://img-ask.csdn.net/upload/202001/06/1578275953_50439.png) ![图片说明](https://img-ask.csdn.net/upload/202001/06/1578275966_288013.png)
今天看了一本spring书,有点疑惑,
在spring中注入datasource, 他用到了jndi(tomcat的), 在tomcat中配置jndi。 然后在spring中注入jndi 我感觉在spring中用jndi是没有必要的, datasource既然可以随时注入, 随时更改,那jndi还有必要吗??? 我做的是小项目,是不是在大项目中有特别的用处啊 [b]问题补充:[/b] jndi我知道,说的不清楚, spring的datasource中注入(jndi)多个连接池。也就能对多个数据库做操作了, 一个项目中要用到多个数据库,我还没有碰到, 想想。。。。。 向银行的业务,工商,邮政,民生....,他们的转账就会用到多个数据库, 那就有分布式的事务了,难啊。。。。。。 看来要学的东西好多啊, [b]问题补充:[/b] 确定一下。jndi就向jdbc一样吧?? 我想他们都是谢协议(接口) [b]问题补充:[/b] 用jndi,spring中也只能注入一个连接池啊,不能注入多个连接池啊,
余额修改和交易流水表添加流水数据事务不一致
我们的余额表放在余额数据库里,订单表放在订单数据库里,交易流水表放在交易流水系统里。所有服务是通过dubbo这个中间件来进行调用的。 现在有个问题就是: 用户支付宝支付了充值订单后,支付回调我们的后台系统,后台会修改订单支付状态为已支付,然后从余额 表里增加余额,但是就是在增加余额的时候成功了,当接下来调用交易流水服务的时候,后台在那一瞬间宕机了。 因为是都是不同的库,事务属于分布式事务,造成余额表修改成功了,但是交易流水表记录流水数据失败了。然后支付宝又再次回调我们后台,导致余额表又修改了一次余额。 现在我的解决办法是加多一张余额费用记录表到余额数据库里头,主要字段就是orderNo(订单号),fee(增加费用) ,如果某订单支付成功了,这个表就会增加一条数据,把余额增加和余额费用记录表做成同一个事务,支付宝每次回调都会先查余额费用记表录里有没有数据 1)没数据就先修改余额,然后插入余额费用记录表 2)有数据,就直接跳过余额加款这个操作 这样目前暂时就是没造成余额修改成功,交易流水表扣款失败,导致支付宝重复回调,重复扣款的问题了。 但是这样我觉得还是不大妥,不知还有什么方案好使。
怪事,tomcat启动过程不读取hibernate配置文件
我在hibernate配置文件里面加了 <property name="hbm2ddl.auto">create</property> 没有效果,然后我随意修改配置文件的内容,比如把数据库密码改错掉,tomcat启动的时候居然没检查出来,这是怎么回事?最近遇到一大堆问题,郁闷死了 [b]问题补充:[/b] struts2 + hibernate 没有用spring,也没有用jndi [b]问题补充:[/b] property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost:3306/hibernate</property> <property name="connection.username">root</property> <property name="connection.password">root</property> <property name="connection.pool_size">5</property> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <property name="current_seccsion_context_class">thread</property> <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> <property name="show_sql">true</property> <property name="hbm2ddl.auto">create</property> <mapping resource="eshop/Items.hbm.xml"/> <mapping resource="eshop/User.hbm.xml"/> [b]问题补充:[/b] 那这么说来,不用spring,<property name="hbm2ddl.auto">create</property> 是不起作用的咯?
CAS 单点登录集成问题,集成其他系统软件,其他系统都有自己独立的用户模块(数据库也不是不同的)
CAS 单点登录集成问题,服务端搭建好后,集成其他系统软件,其他系统都有自己独立的用户模块(数据库也不是不同的),有什么办法能解决一下吗。 还是只能修改其他系统的模块代码。
关于 No suitable driver问题,问题已经解决,但问题本身很奇怪
这个问题之前有过发生,但我都没较真,解决就过去了,但今天认真对比了下发现很奇怪。望大神帮助指点 先说问题: 项目为maven 的 spring mvc+mybatis框架,本地运行了一下后,去tomcat下打包,上传服务器 ,上传后,修改jdbc.properties文件,更改数据库。 之后tomcat正常启动,登录页面正常打开(未访问DB的页面),登录后,开始报错: No suitable driver 。 按网上的说法一一尝试皆无效。 本地服务远程连接DB无问题运行。 后来解决方法:把本地跑的布署项目包直接上传服务器,OK。 返回查问题根本原因。**发现不能远程修改jdbc.properties文件只要动一下就报no suitable driver错误。复制本地的过去就没问题。文字一模一样。** 另外: 本地文件编辑在eclipse中编辑,编码utf-8。 服务器上用的记事本。 我有点怀疑是系统底层编码问题,但实在无头绪理清,在此求教大神帮忙~
关于持久层的测试问题
大家好! 最近在自己做一个项目,老是被一些常规问题卡住,希望大家能够帮我一起想想办法,谢谢了。 1.TOMCAT6.0 中,我在WEB工程的META-INF目录中配置了一个CONTEXT.XML的文件,用来配置应用程序的公共数据源。在程序中用SPRING框架的JNDI访问数据源的方式将数据源加载进去。 问题: a) 目前我的程序大体分为逻辑上的三层:DAO(持久层),SERVICE(业务层),WEB(控制层),DAO层用的技术是IBATIS,之前没有想到需要使用SPRING,所以我直接在SqlMapConfig.properties中配置了链接数据库的相关字符串,直接点说就是用了IBATIS链接数据库的方式进行了数据库的连接,所以在测试的时候非常方便,在持久层内写了一些相关的访问数据库的方法后非常方便的就能够在本地测试这些访问是否成功,详细代码如下: [code="java"] // test mothod must test**** public void testGetUserProfile() { try { UserProfile userProfile = userProfileDaoiBatis .getUserProfile("N0001"); System.out.println(userProfile.getUserName()); System.out.println(userProfile.getTelePhone()); Assert.assertNotNull(userProfile.getUserName()); } catch (Exception e) { e.printStackTrace(); } } [/code] 但是,如果换成了TOMCAT6.0配置数据源的方式,并且用SPRING读取数据源,那是不是每次我JUNIT单体测试的时候都需要启动服务器,发布我的应用程序才行?这样不是很麻烦?有没有更好的方法? b) 我现在用ECLIPSE进行开发,之前都是用MYECLIPSE开发的,我记得用MYECLIPSE的时候每次只要是修改JSP页面的一些元素好像程序都是不需要重新编译的,只有修改了类文件后才需要重新编译并部署一下应用程序。那现在用ECLIPSE我用的是ANT编译和部署应用程序,我的部署是直接将应用程序打成WAR包后再部署到TOMCAT服务器上,虽然执行一下脚本就好了,也很方便,但是如果我是做页面样式的调整,一点点的宽度一点点的调整,那是不是每一次调整都要执行一下脚本。。。。这样太麻烦了,是否有其他更好的方法,能够让页面文件直接能够映射到服务器上的页面文件中?也像MYECLIPSE一样修改页面文件直接可以运行程序查看结果?MYECLIPSE是如何实现的? 谢谢大家!!!
做了一个简单的SSH应用,但启动tomcat时总抛NoClassDefFoundError异常
做了一个简单的SSH应用,但启动tomcat时总抛NoClassDefFoundError异常。 <br />会有<pre name="code" class="java">java.lang.ClassNotFoundException: javax.transaction.TransactionManager</pre> <br />各位一定要帮看看啊!(ssh未入门级) <br /> <br />开发工具:Eclipse3.2+Tomcat5.5+Mysql5.0 <br />建表 <br /><pre name="code" class="java">CREATE TABLE `people` ( `id` int(11) NOT NULL auto_increment, `name` varchar(100) default NULL, `location` varchar(100) default NULL, PRIMARY KEY (`id`) ) </pre> <br /> <br />首先,建立工程和package,以下是我的工程目录 <br />  action <br />      DeletePeopleAction.java     //删除人员action <br />      EditPeopleAction.java         //编辑人员action第一步,读取需要修改的人员资料 <br />       EditPeopleActionDo.java   //修改人员action <br />      ListPeopleAction.javaSave   //显示人员列表action <br />      SavePeopleAction.java         //新增人员action <br />      SearchPeopleAction.java     //查找人员action <br />dao <br />      IDAO.java    //数据库操作接口 <br />       StudentDAOImpl.java  //数据库操作实现 <br />domain <br />      AbstractPeople.java   //实体抽象类 <br />       People.hbm.xml         //数据库映射 <br />       People.java                 //实体类 <br />service <br />      IService.java   //服务层接口 <br />       StudentManagerImpl.java   //服务层实现 <br />util <br />     Character.java   //字符编码过滤器 <br />      PageSupport.java   //分页 <br />applicationContext.xml   //Spring配置文件(hibernate部分和Service部分) <br /> <br />JSP:不详细些了。 <br />   addStudent.jsp <br />   editStudent.jsp <br />   searchList.jsp <br />   searchStudent.jsp <br />   studentList.jsp <br /> <br />我觉得问题就出在 Spring 的xml部署上, <br />或者是我引入的包有冲突,要么就是根本不对。 <br />下面是应用的配置信息: <br />1.web.xml <br /><pre name="code" class="java"><!----> &lt;web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemalocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;/WEB-INF/classes/applicationContext.xml&lt;/param-value&gt; &lt;/context-param&gt; &lt;resource-ref&gt; &lt;description&gt;SqlServer Datasource example&lt;/description&gt; &lt;res-ref-name&gt;jdbc/StudentManager&lt;/res-ref-name&gt; &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt; &lt;res-auth&gt;Container&lt;/res-auth&gt; &lt;/resource-ref&gt; &lt;filter&gt; &lt;filter-name&gt;hibernateFilter&lt;/filter-name&gt; &lt;filter-class&gt; org.springframework.orm.hibernate3.support.OpenSessionInViewFilter &lt;/filter-class&gt; &lt;init-param&gt; &lt;param-name&gt;singleSession&lt;/param-name&gt; &lt;param-value&gt;true&lt;/param-value&gt; &lt;/init-param&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;hibernateFilter&lt;/filter-name&gt; &lt;url-pattern&gt;*.do&lt;/url-pattern&gt; &lt;/filter-mapping&gt; &lt;servlet&gt; &lt;servlet-name&gt;SpringContextServlet&lt;/servlet-name&gt; &lt;servlet-class&gt; org.springframework.web.context.ContextLoaderServlet&lt;/servlet-class&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet&gt; &lt;servlet-name&gt;SpringLog4jConfigServlet&lt;/servlet-name&gt; &lt;servlet-class&gt; org.springframework.web.util.Log4jConfigServlet &lt;/servlet-class&gt; &lt;/servlet&gt; &lt;servlet&gt; &lt;servlet-name&gt;web&lt;/servlet-name&gt; &lt;servlet-class&gt; org.springframework.web.servlet.DispatcherServlet &lt;/servlet-class&gt; &lt;/servlet&gt; &lt;servlet&gt; &lt;servlet-name&gt;action&lt;/servlet-name&gt; &lt;servlet-class&gt;org.apache.struts.action.ActionServlet&lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;config&lt;/param-name&gt; &lt;param-value&gt;/WEB-INF/struts-config.xml&lt;/param-value&gt; &lt;/init-param&gt; &lt;init-param&gt; &lt;param-name&gt;debug&lt;/param-name&gt; &lt;param-value&gt;2&lt;/param-value&gt; &lt;/init-param&gt; &lt;init-param&gt; &lt;param-name&gt;detail&lt;/param-name&gt; &lt;param-value&gt;2&lt;/param-value&gt; &lt;/init-param&gt; &lt;load-on-startup&gt;2&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;action&lt;/servlet-name&gt; &lt;url-pattern&gt;*.do&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;welcome-file-list&gt; &lt;welcome-file&gt;/WEB-INF/jsp/index.jsp&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; &lt;taglib&gt; &lt;taglib-uri&gt;/WEB-INF/struts-bean.tld&lt;/taglib-uri&gt; &lt;taglib-location&gt;/WEB-INF/struts-bean.tld&lt;/taglib-location&gt; &lt;/taglib&gt; &lt;taglib&gt; &lt;taglib-uri&gt;/WEB-INF/struts-html.tld&lt;/taglib-uri&gt; &lt;taglib-location&gt;/WEB-INF/struts-html.tld&lt;/taglib-location&gt; &lt;/taglib&gt; &lt;taglib&gt; &lt;taglib-uri&gt;/WEB-INF/struts-logic.tld&lt;/taglib-uri&gt; &lt;taglib-location&gt;/WEB-INF/struts-logic.tld&lt;/taglib-location&gt; &lt;/taglib&gt; &lt;taglib&gt; &lt;taglib-uri&gt;/WEB-INF/struts-nested.tld&lt;/taglib-uri&gt; &lt;taglib-location&gt;/WEB-INF/struts-nested.tld&lt;/taglib-location&gt; &lt;/taglib&gt; &lt;/web-app&gt; </pre> <br /> <br />2.struts-config.xml <br /><pre name="code" class="java"><!----> &lt;struts-config&gt; &lt;data-sources&gt; &lt;form-beans&gt; &lt;form-bean name="people" type="domain.People"&gt;&lt;/form-bean&gt; &lt;/form-beans&gt; &lt;global-exceptions&gt; &lt;global-forwards&gt; &lt;action-mappings&gt; &lt;action path="/savePeople" name="people" type="action.SavePeopleAction" scope="session" parameter="method"&gt; &lt;forward name="success" path="/listPeople.do"&gt;&lt;/forward&gt; &lt;/action&gt; &lt;action path="/listPeople" name="people" type="action.ListPeopleAction"&gt; &lt;forward name="success" path="/studentList.jsp"&gt;&lt;/forward&gt; &lt;/action&gt; &lt;action path="/deletePeople" name="people" type="action.DeletePeopleAction"&gt; &lt;forward name="success" path="/studentList.jsp"&gt;&lt;/forward&gt; &lt;/action&gt; &lt;action path="/editPeople" name="people" type="action.EditPeopleAction"&gt; &lt;forward name="success" path="/editStudent.jsp"&gt;&lt;/forward&gt; &lt;/action&gt; &lt;action path="/editPeopleDo" name="people" type="action.EditPeopleActionDo"&gt; &lt;forward name="success" path="/studentList.jsp"&gt;&lt;/forward&gt; &lt;/action&gt; &lt;action path="/searchPeople" name="people" type="action.SearchPeopleAction"&gt; &lt;forward name="success" path="/searchList.jsp"&gt;&lt;/forward&gt; &lt;/action&gt; &lt;action path="/test" name="people" type="action.Test"&gt;&lt;/action&gt; &lt;/action-mappings&gt; &lt;controller locale="true"&gt; &lt;message-resources parameter=""&gt; <!----> &lt;/struts-config&gt; </pre> <br /> <br /> <br />3.applicationContext.xml <br /><pre name="code" class="java"><!----> &lt;beans&gt; <!----> &lt;bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" depends-on="sessionFactory"&gt; &lt;property name="sessionFactory"&gt; &lt;ref bean="sessionFactory"&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="studentManager" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"&gt; &lt;property name="transactionManager"&gt; &lt;ref bean="transactionManager"&gt;&lt;/ref&gt; &lt;/property&gt; &lt;property name="target"&gt; &lt;bean class="service.StudentManagerImpl"&gt; &lt;property name="studentDAO"&gt; &lt;ref bean="StudentDAO"&gt; &lt;/property&gt; &lt;/bean&gt; &lt;/property&gt; &lt;property name="transactionAttributes"&gt; &lt;props&gt; &lt;prop key="save*"&gt;PROPAGATION_REQUIRED&lt;/prop&gt; &lt;prop key="list*"&gt;PROPAGATION_REQUIRED,readOnly&lt;/prop&gt; &lt;prop key="delete*"&gt;PROPAGATION_REQUIRED&lt;/prop&gt; &lt;prop key="get*"&gt;PROPAGATION_REQUIRED,readOnly&lt;/prop&gt; &lt;prop key="edit*"&gt;PROPAGATION_REQUIRED&lt;/prop&gt; &lt;prop key="search*"&gt;PROPAGATION_REQUIRED&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;property name="proxyTargetClass"&gt; &lt;value&gt;true&lt;/value&gt; &lt;/property&gt; &lt;/bean&gt; <!----> &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt; &lt;property name="driverClassName"&gt; &lt;value&gt;com.mysql.jdbc.Driver&lt;/value&gt; &lt;/property&gt; &lt;property name="url"&gt; &lt;value&gt;jdbc:mysql://localhost:3306/dbjee&lt;/value&gt; &lt;/property&gt; &lt;property name="username"&gt; &lt;value&gt;root&lt;/value&gt; &lt;/property&gt; &lt;property name="password"&gt; &lt;value&gt;123456&lt;/value&gt; &lt;/property&gt; &lt;/bean&gt; <!----> &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt; &lt;property name="dataSource"&gt; &lt;ref local="dataSource"&gt; &lt;/property&gt; &lt;property name="hibernateProperties"&gt; &lt;props&gt; &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt; &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt; &lt;prop key="hibernate.cache.use_query_cache"&gt;true&lt;/prop&gt; &lt;prop key="hibernate.cache.provider_class"&gt; org.hibernate.cache.HashtableCacheProvider&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; <!----> &lt;property name="mappingResources"&gt; &lt;list&gt; &lt;value&gt;domain/People.hbm.xml&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="StudentDAO" class="dao.StudentDAOImpl"&gt; &lt;property name="sessionFactory"&gt; &lt;ref local="sessionFactory"&gt; &lt;/property&gt; &lt;/bean&gt; &lt;/beans&gt; </pre> <br /> <br />4.People.hbm.xml <br /><pre name="code" class="java"><!----> <!----> &lt;hibernate-mapping package="domain"&gt; &lt;class name="People" table="people"&gt; &lt;id name="id" type="java.lang.Integer"&gt; &lt;column name="id"&gt; &lt;generator class="increment"&gt;&lt;/generator&gt; &lt;/id&gt; &lt;property name="name" type="java.lang.String"&gt; &lt;column name="name" length="100"&gt; &lt;/property&gt; &lt;property name="location" type="java.lang.String"&gt; &lt;column name="location" length="100"&gt; &lt;/property&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </pre> <br /> <br /> <br /><span style="font-size: large;">附件里是我引入的jar包。 <br />希望各位能帮帮忙,困扰我2天,一直出不来。</span> <br /> <br />最后把启动Tomcat时报的错误也贴出来。 <br /><pre name="code" class="java">严重: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/TransactionManager java.lang.NoClassDefFoundError: javax/transaction/TransactionManager at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Unknown Source) at java.lang.Class.getDeclaredMethods(Unknown Source) at java.beans.Introspector$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.beans.Introspector.getPublicDeclaredMethods(Unknown Source) at java.beans.Introspector.getTargetMethodInfo(Unknown Source) at java.beans.Introspector.getBeanInfo(Unknown Source) at java.beans.Introspector.getBeanInfo(Unknown Source) at org.springframework.beans.CachedIntrospectionResults.&lt;init&gt;(CachedIntrospectionResults.java:149) at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:85) at org.springframework.beans.BeanWrapperImpl.setIntrospectionClass(BeanWrapperImpl.java:234) at org.springframework.beans.BeanWrapperImpl.setWrappedInstance(BeanWrapperImpl.java:192) at org.springframework.beans.BeanWrapperImpl.setWrappedInstance(BeanWrapperImpl.java:176) at org.springframework.beans.BeanWrapperImpl.&lt;init&gt;(BeanWrapperImpl.java:129) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:491) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:366) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:144) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:330) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:144) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:283) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:321) at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:139) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:252) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:190) at org.springframework.web.context.ContextLoaderServlet.init(ContextLoaderServlet.java:83) at javax.servlet.GenericServlet.init(GenericServlet.java:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626) at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1150) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022) at org.apache.catalina.core.StandardHost.start(StandardHost.java:736) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:448) at org.apache.catalina.core.StandardServer.start(StandardServer.java:700) at org.apache.catalina.startup.Catalina.start(Catalina.java:552) 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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433) Caused by: java.lang.ClassNotFoundException: javax.transaction.TransactionManager at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1386) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1232) at java.lang.ClassLoader.loadClassInternal(Unknown Source) ... 55 more 2008-11-14 20:08:31 org.apache.catalina.core.ApplicationContext log 严重: StandardWrapper.Throwable org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/TransactionManager java.lang.NoClassDefFoundError: javax/transaction/TransactionManager at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Unknown Source) at java.lang.Class.getDeclaredMethods(Unknown Source) at java.beans.Introspector$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.beans.Introspector.getPublicDeclaredMethods(Unknown Source) at java.beans.Introspector.getTargetMethodInfo(Unknown Source) at java.beans.Introspector.getBeanInfo(Unknown Source) at java.beans.Introspector.getBeanInfo(Unknown Source) at org.springframework.beans.CachedIntrospectionResults.&lt;init&gt;(CachedIntrospectionResults.java:149) at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:85) at org.springframework.beans.BeanWrapperImpl.setIntrospectionClass(BeanWrapperImpl.java:234) at org.springframework.beans.BeanWrapperImpl.setWrappedInstance(BeanWrapperImpl.java:192) at org.springframework.beans.BeanWrapperImpl.setWrappedInstance(BeanWrapperImpl.java:176) at org.springframework.beans.BeanWrapperImpl.&lt;init&gt;(BeanWrapperImpl.java:129) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:491) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:366) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:144) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:330) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:144) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:283) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:321) at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:139) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:252) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:190) at org.springframework.web.context.ContextLoaderServlet.init(ContextLoaderServlet.java:83) at javax.servlet.GenericServlet.init(GenericServlet.java:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626) at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1150) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022) at org.apache.catalina.core.StandardHost.start(StandardHost.java:736) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:448) at org.apache.catalina.core.StandardServer.start(StandardServer.java:700) at org.apache.catalina.startup.Catalina.start(Catalina.java:552) 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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433) Caused by: java.lang.ClassNotFoundException: javax.transaction.TransactionManager at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1386) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1232) at java.lang.ClassLoader.loadClassInternal(Unknown Source) ... 55 more 2008-11-14 20:08:31 org.apache.catalina.core.StandardContext loadOnStartup 严重: Servlet /SSHDemo threw load() exception java.lang.ClassNotFoundException: javax.transaction.TransactionManager at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1386) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1232) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Unknown Source) at java.lang.Class.getDeclaredMethods(Unknown Source) at java.beans.Introspector$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.beans.Introspector.getPublicDeclaredMethods(Unknown Source) at java.beans.Introspector.getTargetMethodInfo(Unknown Source) at java.beans.Introspector.getBeanInfo(Unknown Source) at java.beans.Introspector.getBeanInfo(Unknown Source) at org.springframework.beans.CachedIntrospectionResults.&lt;init&gt;(CachedIntrospectionResults.java:149) at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:85) at org.springframework.beans.BeanWrapperImpl.setIntrospectionClass(BeanWrapperImpl.java:234) at org.springframework.beans.BeanWrapperImpl.setWrappedInstance(BeanWrapperImpl.java:192) at org.springframework.beans.BeanWrapperImpl.setWrappedInstance(BeanWrapperImpl.java:176) at org.springframework.beans.BeanWrapperImpl.&lt;init&gt;(BeanWrapperImpl.java:129) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:491) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:366) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:144) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:330) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:144) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:283) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:321) at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:139) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:252) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:190) at org.springframework.web.context.ContextLoaderServlet.init(ContextLoaderServlet.java:83) at javax.servlet.GenericServlet.init(GenericServlet.java:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626) at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1150) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022) at org.apache.catalina.core.StandardHost.start(StandardHost.java:736) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:448) at org.apache.catalina.core.StandardServer.start(StandardServer.java:700) at org.apache.catalina.startup.Catalina.start(Catalina.java:552) 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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433) 2008-11-14 20:08:32 org.apache.coyote.http11.Http11BaseProtocol start 信息: Starting Coyote HTTP/1.1 on http-8888 2008-11-14 20:08:32 org.apache.jk.common.ChannelSocket init </pre><br /><strong>问题补充</strong><br /><div class="quote_title">zzxplayful 写道</div><div class="quote_div">没有这个包 <br />java.lang.ClassNotFoundException: javax.transaction.TransactionManager  </div> <br />这段异常我看得懂, <br />包括下面的: <br /><pre name="code" class="java">org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/TransactionManager</pre> <br /> <br />都看得懂,我想知道的是解决办法。 <br />比如 <br />javax.transaction.TransactionManager <br />在什么包里? <br />要怎样解决?<br /><strong>问题补充</strong><br /><div class="quote_title">fywcc 写道</div><div class="quote_div">这个是spring里面的  你把SPRING的jar包重新覆盖进去试试</div> <br /> <br />我在Spring包里看了啊, <br />源码都是以 org.springframework.×××× 开始的啊, <br />没有 javax.transcation.** 啊, <br />怎么办?还是需要什么别的包,要么是我的包冲突了。 <br /> <br />我引入了: <br />antlr <br />commons-beanutils.jar <br />commons-digester.jar <br />commons-fileupload.jar <br />commons-logging.jar <br />commons-validator.jar <br />jakarta-oro.jar <br />struts.jar <br /> <br />spring.jar <br /> <br />hibernate3.jar<br /><strong>问题补充</strong><br /><div class="quote_title">jones 写道</div><div class="quote_div">放入jta.jar就行了,找找吧,spring里面应该有,要不就是Hibernate里面有</div> <br />谢谢你。 <br />我把缺少的包都放上了,终于启动Tomcat时候不抛异常,而且也能打开welcome页面了。 <br /> <br />但还有其他问题,明天搞。 <br /> <br />第一次搞SSH,多谢指点啊!
eclipse 导入web项目运行时中文乱码
以前win10的eclipse web项目运行后,里面的中文正常,现在是win8的,直接导入,配置了tomcat运行,从数据库读取的中文显示正常,但是在页面修改 再提交就乱码了,数据库urf8 eclipse也是统一utf8,就算web配置文件中用编码过滤器设置了utf8也没用,请问怎么解决?
springMVC上传图片,可能是我选的路径不对还是啥,在客户端读取存入数据库的路径时,图片不显示。
不知道什么回事,图片就是读不出来,但是看网页源代码,有图片路径,单独访问图片路径也可以读到图片,但是在jsp中读不到,可能是过滤器或者拦截器的原因,不知道了,问问各位大神。 下面时spring MVC上传代码: ``` String path = null; //将当前上下文初始化给 CommonsMutipartResolver (多部分解析器) CommonsMultipartResolver multipartResolver=new CommonsMultipartResolver( request.getSession().getServletContext()); //检查form中是否有enctype="multipart/form-data" if(multipartResolver.isMultipart(request)) { //将request变成多部分request MultipartHttpServletRequest multiRequest=(MultipartHttpServletRequest)request; //获取multiRequest 中所有的文件名 Iterator iter=multiRequest.getFileNames(); while(iter.hasNext()) { //一次遍历所有文件 MultipartFile file=multiRequest.getFile(iter.next().toString()); if(file!=null) { path=request.getServletContext().getRealPath("")+"\\image\\"+file.getOriginalFilename(); //上传 file.transferTo(new File(path)); } } } ``` 存入数据库的路径是这样:D:\Tomcat\apache-tomcat-7.0.42\webapps\students\image\QQ图片20180531181825.jpg,在jsp页面中图片路径就是这个,但是就是显示不出来,请问该怎么修改才能在将图片在jsp页面中显示出来,还有, 我这个是不是没有将图片存到服务器上啊? 求教各位了,谢谢
springMVC+maven,启动报报JNDI的错误,但我没有用到JNDI
要修改一个项目,用的技术有springMVC,maven等,部署到tomcat下,启动时报错。项目中使用的连接池连接数据库,没有使用JNDI,为什么启动时老是去查找JNDI? applicationContext.xml中定义了项目的环境: <!-- local development环境 --> <beans profile="development"> <context:property-placeholder ignore-resource-not-found="true" location="classpath*:/application.properties" /> <!-- Tomcat JDBC连接池 --> <bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driver}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <property name="defaultAutoCommit" value="false" /> </bean> </beans> ``` ``` pom.xml中设置了spring.profiles.active ``` <!-- jetty插件, 设定context path与spring profile --> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>${jetty.version}</version> <configuration> <systemProperties> <systemProperty> <name>spring.profiles.active</name> <value>development</value> </systemProperty> </systemProperties> <useTestClasspath>true</useTestClasspath> <webAppConfig> <contextPath>/${project.artifactId}</contextPath> </webAppConfig> </configuration> </plugin> ``` ==========启动日志========== 13:57:46.586 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [servletConfigInitParams] 13:57:46.586 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [servletContextInitParams] 13:57:46.586 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [jndiProperties] 13:57:46.586 [main] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/spring.profiles.active] 13:57:46.586 [main] DEBUG o.s.jndi.JndiLocatorDelegate - Converted JNDI name [java:comp/env/spring.profiles.active] not found - trying original name [spring.profiles.active]. javax.naming.NameNotFoundException: Name spring.profiles.active is not bound in this Context 13:57:46.586 [main] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [spring.profiles.active] 13:57:46.586 [main] DEBUG o.s.jndi.JndiPropertySource - JNDI lookup for name [spring.profiles.active] threw NamingException with message: Name spring.profiles.active is not bound in this Context. Returning null. 13:57:46.586 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [systemProperties] 13:57:46.586 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [systemEnvironment] 13:57:46.586 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Could not find key 'spring.profiles.active' in any property source. Returning [null] ..... ...... 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.driver' in [environmentProperties] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.driver' in [servletConfigInitParams] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.driver' in [servletContextInitParams] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.driver' in [jndiProperties] 13:57:46.836 [main] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/jdbc.driver] 13:57:46.836 [main] DEBUG o.s.jndi.JndiLocatorDelegate - Converted JNDI name [java:comp/env/jdbc.driver] not found - trying original name [jdbc.driver]. javax.naming.NameNotFoundException: Name jdbc.driver is not bound in this Context 13:57:46.836 [main] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [jdbc.driver] 13:57:46.836 [main] DEBUG o.s.jndi.JndiPropertySource - JNDI lookup for name [jdbc.driver] threw NamingException with message: Name jdbc.driver is not bound in this Context. Returning null. 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.driver' in [systemProperties] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.driver' in [systemEnvironment] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Could not find key 'jdbc.driver' in any property source. Returning [null] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.driver' in [localProperties] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Found key 'jdbc.driver' in [localProperties] with type [String] and value 'com.mysql.jdbc.Driver' 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.url' in [environmentProperties] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.url' in [servletConfigInitParams] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.url' in [servletContextInitParams] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.url' in [jndiProperties] 13:57:46.836 [main] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/jdbc.url] 13:57:46.836 [main] DEBUG o.s.jndi.JndiLocatorDelegate - Converted JNDI name [java:comp/env/jdbc.url] not found - trying original name [jdbc.url]. javax.naming.NameNotFoundException: Name jdbc.url is not bound in this Context 13:57:46.836 [main] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [jdbc.url] 13:57:46.836 [main] DEBUG o.s.jndi.JndiPropertySource - JNDI lookup for name [jdbc.url] threw NamingException with message: Name jdbc.url is not bound in this Context. Returning null. 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.url' in [systemProperties] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.url' in [systemEnvironment] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Could not find key 'jdbc.url' in any property source. Returning [null] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.url' in [localProperties] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Found key 'jdbc.url' in [localProperties] with type [String] and value 'jdbc:mysql://127.0.0.1:3306/drolohq?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull' 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.username' in [environmentProperties] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.username' in [servletConfigInitParams] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.username' in [servletContextInitParams] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.username' in [jndiProperties] 13:57:46.836 [main] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/jdbc.username] 13:57:46.836 [main] DEBUG o.s.jndi.JndiLocatorDelegate - Converted JNDI name [java:comp/env/jdbc.username] not found - trying original name [jdbc.username]. javax.naming.NameNotFoundException: Name jdbc.username is not bound in this Context 13:57:46.836 [main] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [jdbc.username] 13:57:46.836 [main] DEBUG o.s.jndi.JndiPropertySource - JNDI lookup for name [jdbc.username] threw NamingException with message: Name jdbc.username is not bound in this Context. Returning null. 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.username' in [systemProperties] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.username' in [systemEnvironment] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Could not find key 'jdbc.username' in any property source. Returning [null] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.username' in [localProperties] 13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Found key 'jdbc.username' in [localProperties] with type [String] and value 'root'
Struts1.3+spring2.5+hibernate3.2部署tomcat6.0.18报错请教
<p><span style="font-size: small;">Struts1.3+spring2.5+hibernate3.2部署在tomcat6.0.18虽然成功,但是对数据库的查询回报错。 <br>添加修改都能成功。在Myeclipse6.5里运行项目完全没有问题。但是部署到tomcat6.0.18里,查询就报错。</span></p> <p><span style="font-size: small;">郁闷了很久了。希望得到帮助。</span></p> <p><span style="font-size: small;">---------------------------------错误信息--------------------------------</span></p> <p>2009-6-24 17:45:02 org.apache.catalina.core.ApplicationContext log<br>信息: Initializing Spring root WebApplicationContext<br>2009-6-24 17:45:41 org.apache.catalina.core.ApplicationDispatcher invoke<br>严重: Servlet.service() for servlet jsp threw exception<br>javax.servlet.ServletException: javax/servlet/jsp/tagext/Tag<br> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:275)<br> at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)<br> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)<br> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)<br> at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)<br> at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)<br> at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)<br> at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)<br> at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)<br> at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)<br> at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)<br> at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)<br> at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)<br> at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)<br> at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)<br> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)<br> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)<br> at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)<br> at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)<br> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)<br> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)<br> at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)<br> at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)<br> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)<br> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)<br> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)<br> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)<br> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)<br> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)<br> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)<br> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)<br> at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)<br> at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)<br> at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)<br> at java.lang.Thread.run(Thread.java:619)<br>2009-6-24 17:45:41 org.apache.catalina.core.StandardWrapperValve invoke<br>严重: Servlet.service() for servlet action threw exception<br>javax.servlet.ServletException: javax/servlet/jsp/tagext/Tag<br> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:275)<br> at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)<br> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)<br> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)<br> at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)<br> at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)<br> at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)<br> at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)<br> at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)<br> at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)<br> at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)<br> at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)<br> at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)<br> at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)<br> at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)<br> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)<br> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)<br> at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)<br> at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)<br> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)<br> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)<br> at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)<br> at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)<br> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)<br> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)<br> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)<br> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)<br> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)<br> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)<br> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)<br> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)<br> at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)<br> at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)<br> at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)<br> at java.lang.Thread.run(Thread.java:619)</p> <p>-------------------------------------------------------------------------------------------------------------------------</p> <p> </p> <p>先谢谢啦!</p> <p> </p> <p>----------------------------------------------------------------------------------------</p> <p>以我的推测应该是tomcat没有识别出页面标签,也许问题出在servlet-api.jar,或jsp-api.jar上。</p> <p>但是如果把这两个jar加到项目的lib目录里是报错的,貌似环境变量里配也试过了,tomcat的高版本6.0.20和低版本5.5也试过了,都不好使。</p> <p> </p> <p> </p><br /><strong>问题补充:</strong><br />先感谢lovewhzlq的回复,您说的servlet版本低指的是哪里的低,tomcat lib里的,还是说我项目里的jar包版本低。我项目里没有servlet的jar包,因为tomcat都有提供。在myeclipse6.5里运行一点问题都没有。但不知为什么拿出来运行,查询就报错,现在我推断很有可能是就是页面标签的问题。我下面贴上来一个查询后分页的页面。大家再帮忙看看哪里的标签有问题? <br /> <br />&lt;%@ page language="java" pageEncoding="UTF-8"%&gt; <br />&lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%&gt; <br />&lt;%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %&gt; <br />&lt;%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %&gt; <br />&lt;%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %&gt; <br />&lt;%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %&gt; <br />&lt;% <br />String path = request.getContextPath(); <br />String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; <br />%&gt; <br />&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt; <br />&lt;html&gt; <br />&nbsp; &lt;head&gt; <br />&nbsp;&nbsp;&nbsp; &lt;base href="&lt;%=basePath%&gt;"&gt; <br />&nbsp;&nbsp;&nbsp; &lt;title&gt;河北大学综合新闻网&lt;/title&gt; <br />&nbsp; &lt;/head&gt; <br />&nbsp; &lt;body&gt; <br />&nbsp;&nbsp;&nbsp; &lt;center&gt; <br /> &lt;h3&gt; <br /> 回收站 <br /> &lt;/h3&gt; <br /> &lt;table border="2" width="600"&gt; <br /> &lt;tr&gt; <br /> &lt;td&gt; <br /> 标题 <br /> &lt;/td&gt; <br /> &lt;td&gt; <br /> 发布时间 <br /> &lt;/td&gt; <br /> &lt;td&gt; <br /> 状态 <br /> &lt;/td&gt; <br /> &lt;td&gt; <br /> 操作 <br /> &lt;/td&gt; <br /> &lt;/tr&gt; <br /> &lt;c:forEach items="${requestScope['messageList']}" var="message"&gt; <br /> &lt;tr&gt; <br /> &lt;td&gt; <br /> &lt;c:out value="${message.title}" /&gt; <br /> &lt;/td&gt; <br /> &lt;td&gt; <br /> &lt;c:out value="${message.addTime}" /&gt; <br /> &lt;/td&gt; <br /> &lt;td&gt; <br /> &lt;c:if test="${1==message.isPost}"&gt; <br /> 已审核通过 <br /> &lt;/c:if&gt; <br /> &lt;c:if test="${0==message.isPost}"&gt; <br /> 未审核 <br /> &lt;/c:if&gt; <br /> &lt;/td&gt; <br /> &lt;td&gt; <br /> &lt;a href="./getMessage.do?id=&lt;c:out value="${message.id}"/&gt;"&gt;查看详细&lt;/a&gt;&amp;nbsp;&amp;nbsp; <br /> &lt;a href="./setNoDelMessage.do?id=&lt;c:out value="${message.id}"/&gt;" <br /> onclick="javascript:return confirm('您要还原这条信息吗?')"&gt;还原&lt;/a&gt;&amp;nbsp;&amp;nbsp; <br /> &lt;a href="./deleteMessage.do?id=&lt;c:out value="${message.id}"/&gt;" <br /> onclick="javascript:return confirm('您要删除这条信息吗?')"&gt;删除&lt;/a&gt; <br /> &lt;/td&gt; <br /> &lt;tr&gt; <br /> &lt;/c:forEach&gt; <br /> &lt;/table&gt; <br /> &lt;table align="center" width="500"&gt; <br />&nbsp;&nbsp;&nbsp; &lt;tr&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td align="center" colspan="10"&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 每页&lt;bean:write name="messagePage" property="pageSize"/&gt;条记录 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 共&lt;bean:write name="messagePage" property="rowCount"/&gt;条记录 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 当前第(&lt;bean:write name="messagePage" property="currentPage"/&gt;/&lt;bean:write name="messagePage" property="totalPage"/&gt;)页 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;logic:present name="messagePage"&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;html:link page="/listRecycle.do?pno=1"&gt;首页&lt;/html:link&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;logic:equal name="messagePage" property="hasPreviousPage" value="false"&gt;上一页&lt;/logic:equal&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;logic:equal name="messagePage" property="hasPreviousPage" value="true"&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;a href="./listRecycle.do?pno=&lt;bean:write name="messagePage" property="prePage"/&gt;"&gt;上一页&lt;/a&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/logic:equal&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;logic:equal name="messagePage" property="hasNextPage" value="false"&gt;下一页&lt;/logic:equal&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;logic:equal name="messagePage" property="hasNextPage" value="true"&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;a href="./listRecycle.do?pno=&lt;bean:write name="adminPage" property="nextPage"/&gt;"&gt;下一页&lt;/a&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/logic:equal&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;a href="./listRecycle.do?pno=&lt;bean:write name='messagePage' property='totalPage'/&gt;"&gt;末页&lt;/a&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/logic:present&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/td&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/tr&gt; <br />&nbsp;&nbsp;&nbsp; &lt;/table&gt; <br /> &lt;/center&gt; <br />&nbsp; &lt;/body&gt; <br />&lt;/html&gt; <br /><br /><strong>问题补充:</strong><br />----------------------- <br />我工程里的lib下包含了jstl-1.2.jar,standard-1.0.6.jar。会不会是jstl版本低了?<br /><strong>问题补充:</strong><br />我换了您说的1.1和1.0但是还是一直有问题一样的错,不过错误已经确定就是出在jstl上。因为我换成struts1标签展示信息没有问题,一用jstl就报错。 <br />您可否给点您使用jstl的建议或者您配置jstl时候导入的jar版本和tld文件,以及需要注意什么,谢谢。<br /><strong>问题补充:</strong><br />重新导入了一次jstl,用的1.1版本,还是存在问题。tomcat里也安了jstl,而且版本一致,tld也在web.xml里配了,不过还是报最早的错。哎~~我还是用struts标签吧。谢谢您的答复。给分。
数据库的数据无法在jsp中显示出来
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib prefix="frt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <html> <head> <title>成员列表</title> </head> <body> <form name="frmuser"> <table width="60%" border="1" align="center"> <tr> <td align="left">图书列表&nbsp;&nbsp;&nbsp; <input type="button" name="btnadd" value="添加" onclick="useradd()"> <input type="button" name="btnedit" value="修改" onclick="useredit()"> <input type="button" name="btndelete" value="删除" onclick="userdel()"> </td> </tr> </table> <table width="60%" border="1" align="center"> <tr> <td width="10" align="center">选择</td> <td width="40" align="left">姓名</td> <td width="30" align="left">班级</td> <td width="20" align="right">学号</td> </tr> <c:forEach var="user" items="${userlist}" varStatus="vstatus"> <c:if test="${(vstatus.index)%2 == 0}"> <tr class="tr0"> <td class="td1"> <input type="radio" name="userId" value="${user.userId}"> </td> <td>${user.userName}</td> <td>${user.clazz}</td> <td>${user.userNo}</td> </tr> </c:if> <c:if test="${(vstatus.index)%2 == 1}"> <tr class="tr1"> <td class="td1"> <input type="radio" name="userId" value="${user.userId}"> </td> <td>${user.userName}</td> <td>${user.clazz}</td> <td>${user.userNo}</td> </tr> </c:if> </c:forEach> </table> </form> <script language="JavaScript"> function userdel() { var userids=document.getElementsByName("userId"); var isSelected = false; //循环判断是否有选择的用户 for (i = 0; i<userids.length;i++){ if(userids[i].checked){ isSelected=true; } } if (isSelected){ if (confirm("确认删除选择的用户?")) { document.frmuser.action="${pageContext.request.contextPath}/userDelete"; document.frmuser.submit(); } } else { alert("请先选择用户"); } } function useradd() { document.location.replace("${pageContext.request.contextPath}/toUserAdd"); } function useredit() { var userids=document.getElementsByName("userId"); var isSelected=false; //循环判断是否有选择的用户 for (i = 0; i<userids.length;i++){ if(userids[i].checked){ isSelected=true; } } if (isSelected){ document.frmuser.action="${pageContext.request.contextPath}/toUserEdit"; document.frmuser.submit(); } else { alert("请先选择用户"); } } </script> </body> </html> -------------------------------------下面是数据库的代码------------ ![图片说明](https://img-ask.csdn.net/upload/201812/22/1545473267_247553.png) ---------------------------------------下面是jsp运行截图--------------- ![图片说明](https://img-ask.csdn.net/upload/201812/22/1545473334_280085.png)
spring2.5.6 配置 openJpa 异常
最近在做一个小列子,原本是用配置文件方式注入的,之后我想改为用注解的方式注入,问题就出现了。 错误代码如下: [code="java"]2010-2-4 22:18:04 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet default threw exception java.lang.IllegalArgumentException: entityManagerFactory or jpaTemplate is required at org.springframework.orm.jpa.support.JpaDaoSupport.checkDaoConfig(JpaDaoSupport.java:119) at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:671) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:610) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:499) at org.springframework.beans.factory.annotation.InjectionMetadata.injectMethods(InjectionMetadata.java:117) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:253) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:998) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:671) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:610) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1076) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:982) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:329) at com.opensymphony.xwork2.spring.SpringObjectFactory.autoWireBean(SpringObjectFactory.java:168) at com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:155) at com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:129) at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:143) at com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:113) at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:275) at com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:365) at com.opensymphony.xwork2.DefaultActionInvocation.access$000(DefaultActionInvocation.java:38) at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:83) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.<init>(DefaultActionInvocation.java:74) at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189) at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)[code="java"][/code] at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:494) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:619)[/code] java代码如下: [code="java"] @Repository public class ExamDAOImpl extends JpaDaoSupport implements ExamDAO{ private String hql = "from Exam a "; //新增试卷 public void create(Exam exam) { this.getJpaTemplate().persist(exam); } //修改试卷 public void update(Exam exam) { this.getJpaTemplate().merge(exam); } //删除试卷 public void delete(Exam exam) { this.getJpaTemplate().remove(this.getJpaTemplate().merge(exam)); } //根据id获取试卷信息 public Exam query(int id) { Exam exam = this.getJpaTemplate().find(Exam.class, id); return exam; } //获取所有试卷的信息 @SuppressWarnings("unchecked") public List<Exam> queryList() { List<Exam> list = new ArrayList<Exam>(); list = this.getJpaTemplate().find(hql); return list; } } @Namespace("/") @Results({@Result("jsp/examManagement.jsp"), @Result(name="createQuestion", value = "jsp/questionManagement.jsp"), @Result(name="exam", value = "jsp/exam.jsp"), @Result(name="examResult", value = "jsp/examResult.jsp")}) public class ExamAction extends ActionSupport { private static final long serialVersionUID = 5192939935859483841L; //新增试卷信息 public String create() { HttpServletRequest req = ServletActionContext.getRequest(); HttpServletResponse res = ServletActionContext.getResponse(); //获取试卷信息 Exam exam = getExamBean(req, res); //进行新增 getExamService().create(exam); //获取已有的试卷信息 List<Exam> listExams = getExamService().queryList(); //将已有的试卷信息传递给页面 req.setAttribute("listExams", listExams); //存放消息 req.setAttribute("msg", "新增成功"); return SUCCESS; } //修改试卷信息 public String update() { HttpServletRequest req = ServletActionContext.getRequest(); HttpServletResponse res = ServletActionContext.getResponse(); //获取试卷信息 Exam exam = getExamBean(req, res); //进行修改 getExamService().update(exam); //获取已有的试卷信息 List<Exam> listExams = getExamService().queryList(); //将已有的试卷信息传递给页面 req.setAttribute("listExams", listExams); //存放消息 req.setAttribute("msg", "修改成功"); return SUCCESS; } //删除试卷信息 public String delete() { HttpServletRequest req = ServletActionContext.getRequest(); HttpServletResponse res = ServletActionContext.getResponse(); //获取试卷信息 Exam exam = getExamBean(req, res); //进行删除 getExamService().delete(exam); //获取已有的试卷信息 List<Exam> listExams = getExamService().queryList(); //将已有的试卷信息传递给页面 req.setAttribute("listExams", listExams); //存放消息 req.setAttribute("msg", "删除成功"); return SUCCESS; } //设定该试卷下的题目 public String createQuestion() { HttpServletRequest req = ServletActionContext.getRequest(); HttpServletResponse res = ServletActionContext.getResponse(); //获取试卷信息 Exam exam = getExamBean(req, res); exam = getExamService().query(exam.getId()); //获取该试卷题目下已有的题目 Set<Question> listQuestions = exam.getQuestion(); //将该试卷题目下已有的题目信息传递给页面 req.setAttribute("listQuestions", listQuestions); //将该试卷信息传递给页面 req.setAttribute("exam", exam); //存放消息 req.setAttribute("msg", "欢迎进入" + exam.getName() + "试题题目管理系统"); return "createQuestion"; } //进行考试 public String exam() { HttpServletRequest req = ServletActionContext.getRequest(); HttpServletResponse res = ServletActionContext.getResponse(); //获取试卷信息 Exam exam = getExamBean(req, res); exam = getExamService().query(exam.getId()); //将该试卷信息传递给页面 req.setAttribute("exam", exam); //存放消息 req.setAttribute("msg", "欢迎您开始《" + exam.getName() + "》试卷"); return "exam"; } //统计试卷成绩 public String submitExam() { HttpServletRequest req = ServletActionContext.getRequest(); //获取试卷信息 Exam exam = new Exam(); exam = getExamService().query(Integer.valueOf(req.getParameter("examId"))); //定义该此考试的分数 float result = 0f; //获取该试卷下的题目 Set<Question> listQuestions = exam.getQuestion(); Iterator<Question> iterator = listQuestions.iterator(); //获取每个题目下的项目 while (iterator != null && iterator.hasNext()) { Question question = (Question)iterator.next(); //获取该题目下的项目 List<QuestionItem> listQuestionItems = question.getQuestionItem(); //获取用户选择的题目下的项目 Assert.notNull((String)req.getParameter(question.getId() + "")); int questionId = Integer.valueOf((String)req.getParameter(question.getId() + "")); //累计用户提交的题目下的项目 for (int j = 0; listQuestionItems != null && j < listQuestionItems.size(); j++) { QuestionItem questionItem = (QuestionItem)listQuestionItems.get(j); if(questionId == questionItem.getId()) { if (questionItem.getIsOk() == 1) { //统计成绩 result = result + question.getPoint(); break; } } } } //将该试卷信息传递给页面 req.setAttribute("exam", exam); //将成绩传递给页面 req.setAttribute("result", result); //存放消息 req.setAttribute("msg", "欢迎您查看《" + exam.getName() + "》试卷的成绩"); return "examResult"; } public String index() { HttpServletRequest req = ServletActionContext.getRequest(); //获取已有的试卷信息 List<Exam> listExams = getExamService().queryList(); //将已有的试卷信息传递给页面 //System.out.println("listExams.size==="+listExams.size()); req.setAttribute("listExams", listExams); req.setAttribute("msg", "欢迎进入试卷题目管理系统"); return SUCCESS; } //获取试卷业务逻辑 public ExamService getExamService(){ return examService; } //设定试卷业务逻辑 @Autowired public void setExamService(ExamService examService){ this.examService = examService; } private ExamService examService; //获取试题项目业务逻辑 public QuestionItemService getQuestionItemService(){ return questionItemService; } //设定试题项目业务逻辑 @Autowired public void setQuestionItemService(QuestionItemService questionItemService){ this.questionItemService = questionItemService; } private QuestionItemService questionItemService; //封装试卷基本信息 public Exam getExamBean(HttpServletRequest req, HttpServletResponse res) { Exam exam = new Exam(); try { //判断是否是新增或者修改还是删除,如果是新增则不需要id String hh = req.getParameter("examId" + (String)req.getParameter("checkbox") + ""); if (!"".equals(hh) && hh != null) { exam.setId(Integer.valueOf(req.getParameter("examId" + (String)req.getParameter("checkbox") + ""))); } //获取基本信息 exam.setName(((String)req.getParameter("name" + (String)req.getParameter("checkbox") + ""))); } catch (Exception ex) { ex.printStackTrace(); } return exam; } } [/code] struts和spring的配置文件如下: [code="java"] <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <!--表示可以使用动态方法调用,即userAction!delete.action的形式--> <constant name="struts.enable.DynamicMethodInvocation" value="true" /> <!--表示struts处于开发状态--> <constant name="struts.devMode" value="true" /> <constant name="struts.convention.classes.reload" value="true" /> <constant name="struts.objectFactory.spring.autoWire" value="type" /> <!--使用默认的命名空间、即根目录/,在访问的时候,直接http://localhost:8080/webExam/userAction!delete.action--> <!--<package name="default" extends="struts-default"> 定义动态方法调用examAction!*.action <action name="examAction" class="examAction"> <result>jsp/examManagement.jsp</result> <result name="createQuestion">jsp/questionManagement.jsp</result> <result name="exam">jsp/exam.jsp</result> <result name="examResult">jsp/examResult.jsp</result> </action> 定义动态方法调用questionAction!*.action <action name="questionAction" class="questionAction"> <result>jsp/questionManagement.jsp</result> <result name="createItem">jsp/questionItemManagement.jsp</result> </action> 定义动态方法调用questionItemAction!*.action <action name="questionItemAction" class="questionItemAction"> <result>jsp/questionItemManagement.jsp</result> </action> </package>--> </struts> <?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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:http-conf="http://cxf.apache.org/transports/http/configuration" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd" default-lazy-init="true"> <context:component-scan base-package="com.webExam.dao.impl,com.webExam.service.impl"/> <tx:annotation-driven transaction-manager="transactionManager"/> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"> <property name="persistenceUnitName" value="entityManager"/> <property name="jpaProperties"> <props></props> </property> </bean> </beans> [/code] persistence文件如下: [code="java"]<?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <!--定义持久单元--> <persistence-unit name="entityManager" transaction-type="RESOURCE_LOCAL"> <!--这里采用Hibernate提供的持久化类--> <provider>org.hibernate.ejb.HibernatePersistence</provider> <!--定义持久化属性--> <properties> <!--定义方言、fetch深度、是否显示sql--> <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect" /> <property name="hibernate.max_fetch_depth" value="3" /> <property name="hibernate.show_sql" value="true" /> <!--定义是否自动生成表,create表示每次加载都重新生成,update表示每次加载只是更新表--> <property name="hibernate.hbm2ddl.auto" value="update" /> <!--定义数据库连接的相关属性--> <property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver" /> <property name="hibernate.connection.url" value="jdbc:oracle:thin:@localhost:1521:FLOW" /> <!--定义数据库连接的用户名、密码等--> <property name="hibernate.connection.username" value="arch" /> <property name="hibernate.connection.password" value="arch" /> </properties> </persistence-unit> </persistence>[/code]
网上下载的项目-导入ssm小米商城的后台项目访问登录界面login的时候无法跳转到其他页面是怎么回事?
在网上下载的ssm小米商城的后台项目 1:项目没有错误,,, 2:在访问登录界面login的时候- 却无法跳转到其他页面 3:数据库不知道是不是正常 4:我的数据库设置了管理员登录:admin 密码123456 5: 写了个generatorConfig.xml 6:::新增:看到有人回复说数据库的名字没有改: 我用的是mysql 数据库名是:shop 密码是:1234 userId我不知道是要赋值什么值,,一般不是userName吗??但是这个项目中的确实userId ,,所以我也给他 赋值了数据库的用户名 “root”但是这样配置根本就没有用,,同样无法跳转页面:::: 如果配置错了,,麻烦指出来,,非常感谢,,新手新手,,实力有限抱歉 求大神帮助,,,呜呜,,还是跳转不了 数据库图片: ![图片说明](https://img-ask.csdn.net/upload/201812/26/1545786449_770158.png) 数据库配置图: ![图片说明](https://img-ask.csdn.net/upload/201812/26/1545786860_325497.png) 按照网友提出的问题:修改数据库名和密码: 我把connectionURL 的 work_attendance也改成了shop,, 如下: //connectionURL="jdbc:mysql://localhost:3306/work_attendance" connectionURL="jdbc:mysql://localhost:3306/shop" <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/shop" userId="root" password="1234"> </jdbcConnection> 但是还是没有用,,,依然无法跳转,,总感觉没有错误,,,不知道错在哪了。。。。,,,,大神,,大神们求帮助中 代码如下: <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" > <generatorConfiguration> <!--classPathEntry:数据库的JDBC驱动 --> <!-- location="D:\Develop\MvnRepo\mysql\mysql-connector-java\5.1.34\mysql-connector-java-5.1.34.jar"/> --> <classPathEntry location="D:\Users\lydia\workspaceSSH\shopCMS\src\main\webapp\WEB-INF\lib\mysql-connector-java-5.1.34.jar"/> <context id="MysqlTables" targetRuntime="MyBatis3"> <!-- 注意这里面的顺序确定的,不能随变更改 --> <!-- 自定义的分页插件 <plugin type="com.deppon.foss.module.helloworld.shared.PaginationPlugin"/> --> <!-- 可选的(0 or 1) --> <!-- 注释生成器 --> <commentGenerator> <!-- 是否去除自动生成的注释 true:是 : false:否 --> <property name="suppressAllComments" value="true"/> </commentGenerator> <!-- 必须的(1 required) --> <!--数据库连接的信息:驱动类、连接地址、用户名、密码 connectionURL="jdbc:mysql://localhost:3306/work_attendance" --> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/shop" userId="root" password="1234"> </jdbcConnection> ,, 登录界面 ![图片说明](https://img-ask.csdn.net/upload/201812/24/1545659180_616623.jpg) 每次一点击登录: console界面就显示: [DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:845) DispatcherServlet with name 'SpringMVC' processing POST request for [/shopCMS/login/check] [DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:297) Looking up handler method for path /login/check [DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:302) Returning handler method [public java.lang.String com.shop.shopmanager.controller.LoginController.checkLogin(javax.servlet.http.HttpServletRequest) throws java.io.UnsupportedEncodingException,java.security.NoSuchAlgorithmException] [DEBUG][2018-12-24 21:47:08] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:248) Returning cached instance of singleton bean 'loginController' [DEBUG][2018-12-24 21:47:08] org.mybatis.spring.SqlSessionUtils.getSqlSession(SqlSessionUtils.java:104) Creating a new SqlSession [DEBUG][2018-12-24 21:47:08] org.mybatis.spring.SqlSessionUtils.getSqlSession(SqlSessionUtils.java:140) SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7738ee46] was not registered for synchronization because synchronization is not active [DEBUG][2018-12-24 21:47:08] org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:110) Fetching JDBC Connection from DataSource [DEBUG][2018-12-24 21:47:08] org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:86) JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@41131e6d] will not be managed by Spring [DEBUG][2018-12-24 21:47:08] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:139) ==> Preparing: SELECT cu.user_id AS user_id4, login_name, login_password, salt, user_name, real_name, sex, age, pic_img, cu.`status` AS status4, email, telephone, cu.create_time AS create_time4, cu.update_time AS update_time4, cr.role_id AS role_id2, role_name, role_sign, is_system, cr.`status` AS status2, cr.create_time AS create_time2, cr.update_time AS update_time2, cr.remarks AS remarks2, cm.menu_id AS menu_id1, parent_id, menu_type, menu_code, menu_name, sort, href, icon, cm.`status` AS status1, permission, cm.create_time AS create_time1, cm.update_time AS update_time1, cm.remarks AS remarks1 FROM cms_menu cm, cms_role cr, cms_role_menu crm, cms_user cu, cms_user_role cur WHERE crm.role_id = cr.role_id AND crm.menu_id = cm.menu_id AND cur.user_id = cu.user_id AND cur.role_id = cr.role_id AND cu.login_name = ?; [DEBUG][2018-12-24 21:47:08] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:139) ==> Parameters: admin(String) [DEBUG][2018-12-24 21:47:08] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:139) <== Total: 73 [DEBUG][2018-12-24 21:47:08] org.mybatis.spring.SqlSessionUtils.closeSqlSession(SqlSessionUtils.java:168) Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7738ee46] [DEBUG][2018-12-24 21:47:08] org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:327) Returning JDBC Connection to DataSource [DEBUG][2018-12-24 21:47:08] org.apache.shiro.realm.AuthenticatingRealm.getAuthenticationInfo(AuthenticatingRealm.java:569) Looked up AuthenticationInfo [admin] from doGetAuthenticationInfo [DEBUG][2018-12-24 21:47:08] org.apache.shiro.realm.AuthenticatingRealm.cacheAuthenticationInfoIfPossible(AuthenticatingRealm.java:507) AuthenticationInfo caching is disabled for info [admin]. Submitted token: [org.apache.shiro.authc.UsernamePasswordToken - admin, rememberMe=false]. [DEBUG][2018-12-24 21:47:08] org.mybatis.spring.SqlSessionUtils.getSqlSession(SqlSessionUtils.java:104) Creating a new SqlSession [DEBUG][2018-12-24 21:47:08] org.mybatis.spring.SqlSessionUtils.getSqlSession(SqlSessionUtils.java:140) SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@33b81d6e] was not registered for synchronization because synchronization is not active [DEBUG][2018-12-24 21:47:08] org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:110) Fetching JDBC Connection from DataSource [DEBUG][2018-12-24 21:47:08] org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:86) JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@41131e6d] will not be managed by Spring [DEBUG][2018-12-24 21:47:08] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:139) ==> Preparing: SELECT cu.user_id AS user_id4, login_name, login_password, salt, user_name, real_name, sex, age, pic_img, cu.`status` AS status4, email, telephone, cu.create_time AS create_time4, cu.update_time AS update_time4, cr.role_id AS role_id2, role_name, role_sign, is_system, cr.`status` AS status2, cr.create_time AS create_time2, cr.update_time AS update_time2, cr.remarks AS remarks2, cm.menu_id AS menu_id1, parent_id, menu_type, menu_code, menu_name, sort, href, icon, cm.`status` AS status1, permission, cm.create_time AS create_time1, cm.update_time AS update_time1, cm.remarks AS remarks1 FROM cms_menu cm, cms_role cr, cms_role_menu crm, cms_user cu, cms_user_role cur WHERE crm.role_id = cr.role_id AND crm.menu_id = cm.menu_id AND cur.user_id = cu.user_id AND cur.role_id = cr.role_id AND cu.login_name = ?; [DEBUG][2018-12-24 21:47:08] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:139) ==> Parameters: admin(String) [DEBUG][2018-12-24 21:47:08] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:139) <== Total: 73 [DEBUG][2018-12-24 21:47:08] org.mybatis.spring.SqlSessionUtils.closeSqlSession(SqlSessionUtils.java:168) Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@33b81d6e] [DEBUG][2018-12-24 21:47:08] org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:327) Returning JDBC Connection to DataSource 原密码:123456Dts7jk 加密之后的密码为:lZQ/OoEBjTylEoEfxoyWeQ== [DEBUG][2018-12-24 21:47:08] org.apache.shiro.web.servlet.SimpleCookie.addCookieHeader(SimpleCookie.java:226) Added HttpServletResponse Cookie [rememberMe=deleteMe; Path=/shopCMS; Max-Age=0; Expires=Sun, 23-Dec-2018 13:47:08 GMT] [DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdviceChain.invoke(ResponseBodyAdviceChain.java:61) Invoking ResponseBodyAdvice chain for body=login_fail [DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdviceChain.invoke(ResponseBodyAdviceChain.java:83) After ResponseBodyAdvice chain body=login_fail [DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:163) Written [login_fail] as "text/plain;charset=ISO-8859-1" using [org.springframework.http.converter.StringHttpMessageConverter@395cf6a4] [DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1018) Null ModelAndView returned to DispatcherServlet with name 'SpringMVC': assuming HandlerAdapter completed request handling [DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:996) Successfully completed request [DEBUG][2018-12-24 21:47:08] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:248) Returning cached instance of singleton bean 'sqlSessionFactory' [DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:845) DispatcherServlet with name 'SpringMVC' processing GET request for [/shopCMS/login] [DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:297) Looking up handler method for path /login [DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:302) Returning handler method [public java.lang.String com.shop.shopmanager.controller.LoginController.login()] [DEBUG][2018-12-24 21:47:08] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:248) Returning cached instance of singleton bean 'loginController' [DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:931) Last-Modified value for [/shopCMS/login] is: -1 [DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1225) Rendering view [org.springframework.web.servlet.view.JstlView: name 'login'; URL [/WEB-INF/views/login.jsp]] in DispatcherServlet with name 'SpringMVC' [DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:166) Forwarding to resource [/WEB-INF/views/login.jsp] in InternalResourceView 'login' [DEBUG][2018-12-24 21:47:08] org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:996) Successfully completed request [DEBUG][2018-12-24 21:47:08] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:248) Returning cached instance of singleton bean 'sqlSessionFactory' ``` ``` 我的数据库中有admin和密码 123456,,但是就是无法跳转到登录后的页面希望大佬能帮我看看是什么原因》》》 ------------------------------------ 后续添加,,,,麻烦大佬结合上述和下述看看是什么问题,,拜托拜托, 1:数据库用户表信息: ![图片说明](https://img-ask.csdn.net/upload/201812/28/1545962958_570862.png) 2:我的项目结构: ![图片说明](https://img-ask.csdn.net/upload/201812/28/1545962858_134226.png) 3:以下是登录控制器“LoginController”的代码: package com.shop.shopmanager.controller; import java.io.UnsupportedEncodingException; import java.security.NoSuchAlgorithmException; import javax.servlet.http.HttpServletRequest; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.subject.Subject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import com.shop.shopmanager.service.CmsUserService; /** * @Author 康健 * @Date 2017/8/14 14:54 */ @Controller @RequestMapping("login") public class LoginController { @Autowired private CmsUserService cmsUserService; /** * @Author JackWang [www.coder520.com] * @Date 2017/6/18 12:47 * @Description 登录页面 */ @RequestMapping public String login() { return "login"; } /** * @Author JackWang [www.coder520.com] * @Date 2017/6/18 12:47 * @Description 校验登录 */ @RequestMapping("/check") @ResponseBody public String checkLogin(HttpServletRequest request) throws UnsupportedEncodingException, NoSuchAlgorithmException { String username = request.getParameter("username"); String pwd = request.getParameter("password"); UsernamePasswordToken token = new UsernamePasswordToken(username, pwd); // token.setRememberMe(true); Subject subject = SecurityUtils.getSubject(); try { subject.login(token); SecurityUtils.getSubject().getSession().setTimeout(1800000); } catch (Exception e) { return "login_fail"; } return "login_succ"; } /* @RequestMapping("/register") @ResponseBody public String register(@RequestBody User user) throws UnsupportedEncodingException, NoSuchAlgorithmException { userService.createUser(user); return "succ"; }*/ } 4:UsernamePasswordToken 我没有这个类,这好像是一个方法-------网上好像说这是个认证机制,,不知道跳转不了跟这个有没有关系 网上解释:是最常见的用户名/密码的认证机制;同时,由于它实现了RememberMeAuthenticationToken接口,我们可以通过令牌设置“记住我”的功能。 但是,“已记住”和“已认证”是有区别的: 已记住的用户仅仅是非匿名用户,你可以通过subject.getPrincipals()获取用户信息。但是它并非是认证通过的用户,当你访问需要认证用户的功能时,你仍然需要重新提交认证信息。 这一区别可以参考淘宝网站,网站会默认记住登录的用户,再次访问网站时,对于非敏感的页面功能,页面上会显示记住的用户信息,但是当你访问网站账户信息时仍然需要再次进行登录认证。 5: 我的自定义数据库配置“jdbc.properties”: driverClassName=com.mysql.jdbc.Driver validationQuery=SELECT 1 jdbc_url=jdbc:mysql://localhost:3306/shop?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false jdbc_username=root jdbc_password=1234 6:"generatorConfig.xml" 这个就是上面的数据库驱动的配置 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" > <generatorConfiguration> <!--classPathEntry:数据库的JDBC驱动 --> <!-- location="D:\Develop\MvnRepo\mysql\mysql-connector-java\5.1.34\mysql-connector-java-5.1.34.jar"/> --> <classPathEntry location="D:\Users\lydia\workspaceSSH\shopCMS\src\main\webapp\WEB-INF\lib\mysql-connector-java-5.1.34.jar"/> <context id="MysqlTables" targetRuntime="MyBatis3"> <!-- 注意这里面的顺序确定的,不能随变更改 --> <!-- 自定义的分页插件 <plugin type="com.deppon.foss.module.helloworld.shared.PaginationPlugin"/> --> <!-- 可选的(0 or 1) --> <!-- 注释生成器 --> <commentGenerator> <!-- 是否去除自动生成的注释 true:是 : false:否 --> <property name="suppressAllComments" value="true"/> </commentGenerator> <!-- 必须的(1 required) --> <!--数据库连接的信息:驱动类、连接地址、用户名、密码 connectionURL="jdbc:mysql://localhost:3306/work_attendance" --> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/shop" userId="root" password="1234"> </jdbcConnection> <!-- 可选的(0 or 1) --> <!-- 类型转换器或者加类型解析器 --> <!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer true,把JDBC DECIMAL 和 NUMERIC 类型解析为java.math.BigDecimal --> <javaTypeResolver> <property name="forceBigDecimals" value="false"/> </javaTypeResolver> <!-- 必须的(1 required) --> <!-- java模型生成器 --> <!-- targetProject:自动生成代码的位置 --> <javaModelGenerator targetPackage="com.coder520.user.entity" targetProject="D:\Develop\IDEAWorkPlace\work-attendance\src\main\java" > <!--TODO enableSubPackages:是否让schema作为包的后缀 --> <property name="enableSubPackages" value="true"/> <!-- 从数据库返回的值被清理前后的空格 --> <property name="trimStrings" value="true"/> </javaModelGenerator> <!-- 必须的(1 required) --> <!-- map xml 生成器 <sqlMapGenerator targetPackage="com.coder520.user.dao" targetProject="D:\Develop\IDEAWorkPlace\work-attendance\src\main\java"> <property name="enableSubPackages" value="true"/> </sqlMapGenerator> --> <sqlMapGenerator targetPackage="com.coder520.user.dao" targetProject="D:\Users\lydia\workspaceSSH\shopCMS\src\main\java"> <property name="enableSubPackages" value="true"/> </sqlMapGenerator> <!-- 可选的(0 or 1) --> <!-- mapper 或者就是dao接口生成器 --> <javaClientGenerator targetPackage="com.coder520.user.dao" targetProject="D:\Users\lydia\workspaceSSH\shopCMS\src\main\java" type="XMLMAPPER"> <property name="enableSubPackages" value="true"/> </javaClientGenerator> <!-- 必须的(1...N) --> <!-- pojo 实体生成器 --> <!-- tableName:用于自动生成代码的数据库表;domainObjectName:对应于数据库表的javaBean类名 --> <!-- schema即为数据库名 可不写 --> <table tableName="role" domainObjectName="Role" enableInsert="true" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <!-- 忽略字段 可选的(0 or 1) --> <!-- <ignoreColumn column="is_use" /> --> <!--//无论字段是什么类型,生成的类属性都是varchar。 可选的(0 or 1) 测试无效 --> <!-- <columnOverride column="city_code" jdbcType="VARCHAR" /> --> </table> <table tableName="permission" domainObjectName="Permission" enableInsert="true" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <!-- 忽略字段 可选的(0 or 1) --> <!-- <ignoreColumn column="is_use" /> --> <!--//无论字段是什么类型,生成的类属性都是varchar。 可选的(0 or 1) 测试无效 --> <!-- <columnOverride column="city_code" jdbcType="VARCHAR" /> --> </table> </context> </generatorConfiguration> 万分感谢大佬,,,,,帮我解决这问题我就认你当师傅,,,大佬 ,,拜托了,,,还需要什么麻烦留下言哈
微信小程序本地测试没问题,体验版没问题,审核时报错被驳回
## 问题描述: 之前给公司做了个小程序,上线之后没有问题,审核也通过了,近期有需求做了一些更改(改动不大),这是背景。 然后这次提交审核之后,被驳回了,原因是小程序无法正常使用,看了下审核反馈的截图,登录未成功,报错了。 我立马用体验版测试,因为体验版就是审核的代码,后台连接的服务器程序也是完全一致的,结果亮点来了,我体验版**完美运行** 后来又测试了本地版本,又用了各种方式测试了体验版本,都没有问题,再次提交审核,不出意外,又毙了。。 拉出审核人员登录时的后台日志: ``` ================================================================================================================================================================================================================================================ ==========================日志开始====================== ================================================================================================================================================================================================================================================ 开始计时:07:42:04.389 URI : /fleetif/fleet/loginFleet Controller : com.organ.controller.fleet.FleetLoginController Method : loginFleet Method Type : POST contentType : application/json Params : {"tel":"10001000","checkCode":"1234"} [DEBUG] 2019-12-09 19:42:04 AbstractMessageConverterMethodArgumentResolver.java DEBUG method:org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:197) Read [class com.organ.entity.fleet.FleetUser] as "application/json;charset=UTF-8" with [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@47b74fce] [DEBUG] 2019-12-09 19:42:04 SqlSessionUtils.java DEBUG method:org.mybatis.spring.SqlSessionUtils.getSqlSession(SqlSessionUtils.java:109) Creating a new SqlSession [DEBUG] 2019-12-09 19:42:04 SqlSessionUtils.java DEBUG method:org.mybatis.spring.SqlSessionUtils.getSqlSession(SqlSessionUtils.java:145) SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@18c7d16e] was not registered for synchronization because synchronization is not active [DEBUG] 2019-12-09 19:42:04 DataSourceUtils.java DEBUG method:org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:110) Fetching JDBC Connection from DataSource [DEBUG] 2019-12-09 19:42:04 SpringManagedTransaction.java DEBUG method:org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:88) JDBC Connection [org.apache.commons.dbcp.PoolableConnection@22754112] will not be managed by Spring [DEBUG] 2019-12-09 19:42:04 BaseJdbcLogger.java DEBUG method:org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:139) ==> Preparing: SELECT id, user_name userName, tel, user_type userType, state, balance, balance_state balanceState, parent_id parentId, check_code checkCode, create_time createTime, is_del isDel, unit_price_0 unitPrice0, unit_price_10 unitPrice10 FROM `fleet_user` WHERE tel = ? AND is_del = ? [DEBUG] 2019-12-09 19:42:04 SQLErrorCodeSQLExceptionTranslator.java DEBUG method:org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:281) Unable to translate SQLException with Error code '0', will now try the fallback translator [DEBUG] 2019-12-09 19:42:04 SqlSessionUtils.java DEBUG method:org.mybatis.spring.SqlSessionUtils.closeSqlSession(SqlSessionUtils.java:173) Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@18c7d16e] [DEBUG] 2019-12-09 19:42:04 DataSourceUtils.java DEBUG method:org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:329) Returning JDBC Connection to DataSource [DEBUG] 2019-12-09 19:42:04 DataSourceUtils.java DEBUG method:org.springframework.jdbc.datasource.DataSourceUtils.releaseConnection(DataSourceUtils.java:299) Could not close JDBC Connection java.sql.SQLException: Already closed. at org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.java:114) at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:191) at org.springframework.jdbc.datasource.DataSourceUtils.doCloseConnection(DataSourceUtils.java:343) at org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:330) at org.springframework.jdbc.datasource.DataSourceUtils.releaseConnection(DataSourceUtils.java:296) at org.mybatis.spring.transaction.SpringManagedTransaction.close(SpringManagedTransaction.java:125) at org.apache.ibatis.executor.BaseExecutor.close(BaseExecutor.java:83) at org.apache.ibatis.executor.CachingExecutor.close(CachingExecutor.java:61) at org.apache.ibatis.session.defaults.DefaultSqlSession.close(DefaultSqlSession.java:210) at org.mybatis.spring.SqlSessionUtils.closeSqlSession(SqlSessionUtils.java:175) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:375) at com.sun.proxy.$Proxy51.selectOne(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:163) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:68) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) at com.sun.proxy.$Proxy59.findFleetUser(Unknown Source) at com.organ.service.fleet.FleetUserService.findFleetUser(FleetUserService.java:39) at com.organ.service.fleet.FleetUserService$$FastClassBySpringCGLIB$$888fc21f.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:669) at com.organ.service.fleet.FleetUserService$$EnhancerBySpringCGLIB$$726af94b.findFleetUser(<generated>) at com.organ.controller.fleet.FleetLoginController.loginFleet(FleetLoginController.java:104) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) at javax.servlet.http.HttpServlet.service(HttpServlet.java:660) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at com.organ.filter.PostRequestFilter.doFilter(PostRequestFilter.java:35) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.logging.log4j.core.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:66) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:808) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) [DEBUG] 2019-12-09 19:42:04 AbstractMessageConverterMethodProcessor.java DEBUG method:org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:234) Written [com.organ.controller.base.ResultData@13c8038d] as "application/json" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@47b74fce] [DEBUG] 2019-12-09 19:42:04 LogInterceptor.java DEBUG method:com.organ.interceptor.LogInterceptor.postHandle(LogInterceptor.java:118) --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- CostTime : 8ms --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [DEBUG] 2019-12-09 19:42:04 DispatcherServlet.java DEBUG method:org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1048) Null ModelAndView returned to DispatcherServlet with name 'springDispatcherServlet': assuming HandlerAdapter completed request handling [DEBUG] 2019-12-09 19:42:04 LogInterceptor.java DEBUG method:com.organ.interceptor.LogInterceptor.afterCompletion(LogInterceptor.java:142) 计时结束:07:42:04.397 耗时:8 URI:/fleetif/fleet/loginFleet [DEBUG] 2019-12-09 19:42:04 LogInterceptor.java DEBUG method:com.organ.interceptor.LogInterceptor.afterCompletion(LogInterceptor.java:149) --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [DEBUG] 2019-12-09 19:42:04 FrameworkServlet.java DEBUG method:org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1000) Successfully completed request [DEBUG] 2019-12-09 19:42:33 PostRequestFilter.java DEBUG method:com.organ.filter.PostRequestFilter.doFilter(PostRequestFilter.java:27) ------------------------PostRequestFilter doFilter execute!!! [DEBUG] 2019-12-09 19:42:33 DispatcherServlet.java DEBUG method:org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:869) DispatcherServlet with name 'springDispatcherServlet' processing POST request for [/fleetif/fleet/smsCode] [DEBUG] 2019-12-09 19:42:33 AbstractHandlerMethodMapping.java DEBUG method:org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:310) Looking up handler method for path /fleet/smsCode [DEBUG] 2019-12-09 19:42:33 AbstractHandlerMethodMapping.java DEBUG method:org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:317) Returning handler method [public java.lang.Object com.organ.controller.fleet.FleetLoginController.smsCode(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)] [DEBUG] 2019-12-09 19:42:33 AbstractBeanFactory.java DEBUG method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251) Returning cached instance of singleton bean 'fleetLoginController' [DEBUG] 2019-12-09 19:42:33 LogInterceptor.java DEBUG method:com.organ.interceptor.LogInterceptor.preHandle(LogInterceptor.java:90) ``` 可以看到数据库报了个错,但是这个错什么原因目前查不出来,而且我们无法复现,我们测试一切正常,只要审核人员登录就会报这个错误。 有没有大神指导一下,现在头都大了。。。
爬虫福利二 之 妹子图网MM批量下载
爬虫福利一:27报网MM批量下载    点击 看了本文,相信大家对爬虫一定会产生强烈的兴趣,激励自己去学习爬虫,在这里提前祝:大家学有所成! 目标网站:妹子图网 环境:Python3.x 相关第三方模块:requests、beautifulsoup4 Re:各位在测试时只需要将代码里的变量 path 指定为你当前系统要保存的路径,使用 python xxx.py 或IDE运行即可。
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、PDF搜索网站推荐 对于大部
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 顺便拉下票,我在参加csdn博客之星竞选,欢迎投票支持,每个QQ或者微信每天都可以投5票,扫二维码即可,http://m234140.nofollow.ax.
Vue + Spring Boot 项目实战(十四):用户认证方案与完善的访问拦截
本篇文章主要讲解 token、session 等用户认证方案的区别并分析常见误区,以及如何通过前后端的配合实现完善的访问拦截,为下一步权限控制的实现打下基础。
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入  假设现有4个人
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 欢迎 改进 留言。 演示地点跳到演示地点 html代码如下`&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;music&lt;/title&gt; &lt;meta charset="utf-8"&gt
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。 1. for - else 什么?不是 if 和 else 才
数据库优化 - SQL优化
前面一篇文章从实例的角度进行数据库优化,通过配置一些参数让数据库性能达到最优。但是一些“不好”的SQL也会导致数据库查询变慢,影响业务流程。本文从SQL角度进行数据库优化,提升SQL运行效率。 判断问题SQL 判断SQL是否有问题时可以通过两个表象进行判断: 系统级别表象 CPU消耗严重 IO等待严重 页面响应时间过长
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 c/c++ 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7
通俗易懂地给女朋友讲:线程池的内部原理
餐厅的约会 餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”我楞了一下,心里想女朋友今天是怎么了,怎么突然问出这么专业的问题,但做为一个专业人士在女朋友面前也不能露怯啊,想了一下便说:“我先给你讲讲我前同事老王的故事吧!” 大龄程序员老王 老王是一个已经北漂十多年的程序员,岁数大了,加班加不动了,升迁也无望,于是拿着手里
经典算法(5)杨辉三角
写在前面: 我是 扬帆向海,这个昵称来源于我的名字以及女朋友的名字。我热爱技术、热爱开源、热爱编程。技术是开源的、知识是共享的。 这博客是对自己学习的一点点总结及记录,如果您对 Java、算法 感兴趣,可以关注我的动态,我们一起学习。 用知识改变命运,让我们的家人过上更好的生活。 目录一、杨辉三角的介绍二、杨辉三角的算法思想三、代码实现1.第一种写法2.第二种写法 一、杨辉三角的介绍 百度
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹
面试官:你连RESTful都不知道我怎么敢要你?
面试官:了解RESTful吗? 我:听说过。 面试官:那什么是RESTful? 我:就是用起来很规范,挺好的 面试官:是RESTful挺好的,还是自我感觉挺好的 我:都挺好的。 面试官:… 把门关上。 我:… 要干嘛?先关上再说。 面试官:我说出去把门关上。 我:what ?,夺门而去 文章目录01 前言02 RESTful的来源03 RESTful6大原则1. C-S架构2. 无状态3.统一的接
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看
SQL-小白最佳入门sql查询一
一 说明 如果是初学者,建议去网上寻找安装Mysql的文章安装,以及使用navicat连接数据库,以后的示例基本是使用mysql数据库管理系统; 二 准备前提 需要建立一张学生表,列分别是id,名称,年龄,学生信息;本示例中文章篇幅原因SQL注释略; 建表语句: CREATE TABLE `student` ( `id` int(11) NOT NULL AUTO_INCREMENT, `
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // dosho
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,
程序员:我终于知道post和get的区别
IT界知名的程序员曾说:对于那些月薪三万以下,自称IT工程师的码农们,其实我们从来没有把他们归为我们IT工程师的队伍。他们虽然总是以IT工程师自居,但只是他们一厢情愿罢了。 此话一出,不知激起了多少(码农)程序员的愤怒,却又无可奈何,于是码农问程序员。 码农:你知道get和post请求到底有什么区别? 程序员:你看这篇就知道了。 码农:你月薪三万了? 程序员:嗯。 码农:你是怎么做到的? 程序员:
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
      11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1
程序员把地府后台管理系统做出来了,还有3.0版本!12月7号最新消息:已在开发中有github地址
第一幕:缘起 听说阎王爷要做个生死簿后台管理系统,我们派去了一个程序员…… 996程序员做的梦: 第一场:团队招募 为了应对地府管理危机,阎王打算找“人”开发一套地府后台管理系统,于是就在地府总经办群中发了项目需求。 话说还是中国电信的信号好,地府都是满格,哈哈!!! 经常会有外行朋友问:看某网站做的不错,功能也简单,你帮忙做一下? 而这次,面对这样的需求,这个程序员
Android 9.0系统新特性,对刘海屏设备进行适配
其实Android 9.0系统已经是去年推出的“老”系统了,这个系统中新增了一个比较重要的特性,就是对刘海屏设备进行了支持。一直以来我也都有打算针对这个新特性好好地写一篇文章,但是为什么直到拖到了Android 10.0系统都发布了才开始写这篇文章呢?当然,一是因为我这段时间确实比较忙,今年几乎绝大部分的业余时间都放到写新书上了。但是最主要的原因并不是这个,而是因为刘海屏设备的适配存在一定的特殊性
网易云6亿用户音乐推荐算法
网易云音乐是音乐爱好者的集聚地,云音乐推荐系统致力于通过 AI 算法的落地,实现用户千人千面的个性化推荐,为用户带来不一样的听歌体验。 本次分享重点介绍 AI 算法在音乐推荐中的应用实践,以及在算法落地过程中遇到的挑战和解决方案。 将从如下两个部分展开: AI 算法在音乐推荐中的应用 音乐场景下的 AI 思考 从 2013 年 4 月正式上线至今,网易云音乐平台持续提供着:乐屏社区、UGC
【技巧总结】位运算装逼指南
位算法的效率有多快我就不说,不信你可以去用 10 亿个数据模拟一下,今天给大家讲一讲位运算的一些经典例子。不过,最重要的不是看懂了这些例子就好,而是要在以后多去运用位运算这些技巧,当然,采用位运算,也是可以装逼的,不信,你往下看。我会从最简单的讲起,一道比一道难度递增,不过居然是讲技巧,那么也不会太难,相信你分分钟看懂。 判断奇偶数 判断一个数是基于还是偶数,相信很多人都做过,一般的做法的代码如下
日均350000亿接入量,腾讯TubeMQ性能超过Kafka
整理 | 夕颜出品 | AI科技大本营(ID:rgznai100) 【导读】近日,腾讯开源动作不断,相继开源了分布式消息中间件TubeMQ,基于最主流的 OpenJDK8开发的
8年经验面试官详解 Java 面试秘诀
    作者 | 胡书敏 责编 | 刘静 出品 | CSDN(ID:CSDNnews) 本人目前在一家知名外企担任架构师,而且最近八年来,在多家外企和互联网公司担任Java技术面试官,前后累计面试了有两三百位候选人。在本文里,就将结合本人的面试经验,针对Java初学者、Java初级开发和Java开发,给出若干准备简历和准备面试的建议。   Java程序员准备和投递简历的实
面试官如何考察你的思维方式?
1.两种思维方式在求职面试中,经常会考察这种问题:北京有多少量特斯拉汽车? 某胡同口的煎饼摊一年能卖出多少个煎饼? 深圳有多少个产品经理? 一辆公交车里能装下多少个乒乓球? 一
相关热词 c# 图片上传 c# gdi 占用内存 c#中遍历字典 c#控制台模拟dos c# 斜率 最小二乘法 c#进程延迟 c# mysql完整项目 c# grid 总行数 c# web浏览器插件 c# xml 生成xsd
立即提问