学习用MyEclipse 2013开发SSH项目遇到java.lang.NullPointerException问题,请帮助!

SaveOfficeAction.java出错:java.lang.NullPointerException

package we.app.action;

import we.app.data.*;

import com.opensymphony.xwork2.ActionSupport;

public class SaveOfficeAction extends ActionSupport {
    private IOffice B_Office;
    private IOfficeDAO B_OfficeDAO;
    private String Tips;

    public IOffice getB_Office() {
        return B_Office;
    }

    public void setB_Office(IOffice b_Office) {
        B_Office = b_Office;
    }

    public IOfficeDAO getB_OfficeDAO() {
        return B_OfficeDAO;
    }

    public void setB_OfficeDAO(IOfficeDAO b_OfficeDAO) {
        B_OfficeDAO = b_OfficeDAO;
    }

    public String getTips() {
        return Tips;
    }

    public void setTips(String tips) {
        Tips = tips;
    }

    public String execute() throws Exception
    {
        this.Tips=this.getB_OfficeDAO().findById(1).getOfficename().toString();
        //this.Trans_OfficeDAO.save(this.B_Office);
        return SUCCESS;
    }


}

1、index.jsp:

   <%@taglib uri="/struts-tags" prefix="s"%><%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">

    <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
  </head>

  <body>
    <s:form action="SaveOffice">
        <s:textfield name="B_Office.officename" label="officename"></s:textfield>
        <s:submit></s:submit>
    </s:form>
    <br>
  </body>
</html>

2、hibernate.cfg.xml:

   <?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>

    <session-factory>
        <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
        <property name="connection.url">
            jdbc:jtds:sqlserver://192.168.0.100:4628/tnew
        </property>
        <property name="connection.username">sa</property>
        <property name="connection.password">111</property>
        <property name="connection.driver_class">
            net.sourceforge.jtds.jdbc.Driver
        </property>
        <property name="myeclipse.connection.profile">
            sqlserverjtds
        </property>
        <mapping resource="we/app/data/Peop.hbm.xml" />
        <mapping resource="we/app/data/Office.hbm.xml" />

    </session-factory>

</hibernate-configuration>

3、ApplicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xmlns:aop="http://www.springframework.org/schema/aop" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
           http://www.springframework.org/schema/tx 
           http://www.springframework.org/schema/tx/spring-tx-3.1.xsd 
           http://www.springframework.org/schema/aop 
           http://www.springframework.org/schema/aop/spring-aop-3.1.xsd"
    >


    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="configLocation"
            value="classpath:hibernate.cfg.xml">
        </property>
    </bean>

    <bean id="PeopDAO" class="we.app.data.PeopDAO">
            <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    <bean id="B_OfficeDAO" class="we.app.data.OfficeDAO">
    <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>

    <bean id="B_Office" class="we.app.data.Office"></bean>
    <bean id="B_Peop" class="we.app.data.Peop"></bean>


    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
       <property name="sessionFactory">
         <ref bean="sessionFactory"/>
       </property>
    </bean>

<bean id="Trans_OfficeDAO"
  class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
  <property name="transactionManager">
   <ref bean="transactionManager" />
  </property>
  <property name="target">
   <ref local="B_OfficeDAO" />
  </property>
  <property name="transactionAttributes">
   <props>
    <prop key="*">PROPAGATION_REQUIRED</prop>
   </props>
  </property>
 </bean>


</beans>

4、

package we.app.data;

import java.util.List;

public interface IOfficeDAO {

    // property constants
    public static final String OFFICENAME = "officename";

    public abstract void save(IOffice transientInstance);

    public abstract void delete(IOffice persistentInstance);

    public abstract IOffice findById(java.lang.Integer id);

    public abstract List findByExample(IOffice instance);

    public abstract List findByProperty(String propertyName, Object value);

    public abstract List findByOfficename(Object officename);

    public abstract List findAll();

    public abstract IOffice merge(Office detachedInstance);

    public abstract void attachDirty(IOffice instance);

    public abstract void attachClean(IOffice instance);

}
suannai0314
鹳狸媛 楼主的这个问题解决了么?下边的答案能解决问题么?如果可以麻烦点击答案旁的√采纳哦~如果没有也可以将自己的答案贴上然后进行采纳的。
6 年多之前 回复

2个回答

你好歹把出错信息贴出来啊

suannai0314
鹳狸媛 你这个可以直接在问题下边添加评论
6 年多之前 回复

this.Tips=this.getB_OfficeDAO().findById(1).getOfficename().toString();中的B_officeDao是不是没有在你的action里面注入,也木有申明;要不你干脆new 一个B_officeDao在试试,要不你再你的Application.xml配置文件中加上一条

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
java.lang.NoClassDefFoundError: javax/servlet/Servlet
tomcat6.0和MyEclipse发布网站服务端,总是报这个错误,百度了很多方法都没有解决掉问题,求帮助 type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/servlet/Servlet org.apache.jasper.servlet.JspServlet.service(JspServlet.java:268) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) root cause java.lang.NoClassDefFoundError: javax/servlet/Servlet java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClass(Unknown Source) java.security.SecureClassLoader.defineClass(Unknown Source) java.net.URLClassLoader.defineClass(Unknown Source) java.net.URLClassLoader.access$100(Unknown Source) java.net.URLClassLoader$1.run(Unknown Source) java.net.URLClassLoader$1.run(Unknown Source) java.security.AccessController.doPrivileged(Native Method) java.net.URLClassLoader.findClass(Unknown Source) java.lang.ClassLoader.loadClass(Unknown Source) java.lang.ClassLoader.loadClass(Unknown Source) java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClass(Unknown Source) java.security.SecureClassLoader.defineClass(Unknown Source) java.net.URLClassLoader.defineClass(Unknown Source) java.net.URLClassLoader.access$100(Unknown Source) java.net.URLClassLoader$1.run(Unknown Source) java.net.URLClassLoader$1.run(Unknown Source) java.security.AccessController.doPrivileged(Native Method) java.net.URLClassLoader.findClass(Unknown Source) java.lang.ClassLoader.loadClass(Unknown Source) ……………………
web开发中遇到java.lang.ClassFormatError应该怎么解决?谢谢各位大牛:)?
我做的项目,有好多个java文件,根据错误提示,应该怎么解决!谢谢各位大牛! MyEclipse8.5中控制台信息如下: 2015-5-6 8:31:03 org.apache.catalina.core.AprLifecycleListener init 信息: Loaded APR based Apache Tomcat Native library 1.1.32 using APR version 1.5.1. 2015-5-6 8:31:03 org.apache.catalina.core.AprLifecycleListener init 信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true]. 2015-5-6 8:31:04 org.apache.catalina.core.AprLifecycleListener initializeSSL 信息: OpenSSL successfully initialized with version OpenSSL 1.0.1j 15 Oct 2014 2015-5-6 8:31:04 org.apache.coyote.http11.Http11AprProtocol init 信息: Initializing Coyote HTTP/1.1 on http-8080 2015-5-6 8:31:04 org.apache.coyote.ajp.AjpAprProtocol init 信息: Initializing Coyote AJP/1.3 on ajp-8009 2015-5-6 8:31:04 org.apache.catalina.startup.Catalina load 信息: Initialization processed in 1126 ms 2015-5-6 8:31:04 org.apache.catalina.core.StandardService start 信息: Starting service Catalina 2015-5-6 8:31:04 org.apache.catalina.core.StandardEngine start 信息: Starting Servlet Engine: Apache Tomcat/6.0.43 2015-5-6 8:31:04 org.apache.catalina.startup.HostConfig deployDescriptor 信息: Deploying configuration descriptor host-manager.xml 2015-5-6 8:31:05 org.apache.catalina.startup.HostConfig deployDescriptor 信息: Deploying configuration descriptor manager.xml 2015-5-6 8:31:05 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory docs 2015-5-6 8:31:05 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory examples 2015-5-6 8:31:05 org.apache.catalina.core.ApplicationContext log 信息: ContextListener: contextInitialized() 2015-5-6 8:31:05 org.apache.catalina.core.ApplicationContext log 信息: SessionListener: contextInitialized() 2015-5-6 8:31:05 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory MyContent 2015-5-6 8:31:05 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory ROOT 2015-5-6 8:31:05 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory test_online 2015-5-6 8:31:05 org.apache.coyote.http11.Http11AprProtocol start 信息: Starting Coyote HTTP/1.1 on http-8080 2015-5-6 8:31:05 org.apache.coyote.ajp.AjpAprProtocol start 信息: Starting Coyote AJP/1.3 on ajp-8009 2015-5-6 8:31:05 org.apache.catalina.startup.Catalina start 信息: Server startup in 1269 ms 2015-5-6 8:32:34 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet SaveServlet threw exception java.lang.ClassFormatError: Illegal exception table range in class file com/mysql/jdbc/ConnectionImpl at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2854) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:347) at java.sql.DriverManager.getConnection(DriverManager.java:582) at java.sql.DriverManager.getConnection(DriverManager.java:185) at util.DBUtil.getConnection(DBUtil.java:11) at dao.impl.SaveDaoImpl.save(SaveDaoImpl.java:16) at service.impl.SaveServiceImpl.save(SaveServiceImpl.java:11) at servlet.SaveServlet.doPost(SaveServlet.java:25) at javax.servlet.http.HttpServlet.service(HttpServlet.java:643) at javax.servlet.http.HttpServlet.service(HttpServlet.java:723) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 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:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879) at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:617) at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1778) at java.lang.Thread.run(Thread.java:619) 页面运行截图如下:![图片说明](https://img-ask.csdn.net/upload/201505/06/1430873308_416927.png)
java.lang.UnsupportedClassVersionError: Bad versio
就是在main函数中在引用jxl.jar包 测试读取EXCEL内容时报错(jdk是1.5,jxl.jar版本是_2_6_9),具体错误信息: java.lang.UnsupportedClassVersionError: Bad version number in .class file at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:620) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$100(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) Exception in thread "main" 不知道是什么版本错误,找了半天没找出是哪个地方的错,请各位大侠给看下,谢谢 ! [b]问题补充:[/b] 谢谢您的关注,是在Myeclipse下运行的,可是我的jdk版本是1.5,用的时Myeclipse6.0 这样会有问题吗?
java.lang.OutOfMemoryError: PermGen space
项目是用:Spring+Struts2+Mybatis开发的, 服务器:Tomcat7.x IDE:MyEclipse10 在项目启动时报内存溢出异常(java.lang.OutOfMemoryError: PermGen space)
java.lang.NoSuchMethodError
启动weblogic报错信息如下: org.springframework.beans.factory.BeanCreationException: Error creating bean wit h name 'transactionManager' defined in file [D:\Workspaces\MyEclipse 8.5\salesV2 .0Current_1061_C00_20140806\webapp\WEB-INF\classes\spring\applicationContext-hib ernate.xml]: Initialization of bean failed; nested exception is org.springframew ork.beans.factory.BeanCreationException: Error creating bean with name 'dataSour ce' defined in file [D:\Workspaces\MyEclipse 8.5\salesV2.0Current_1061_C00_20140 806\webapp\WEB-INF\classes\spring\dataAccessContext-hibernate.xml]: Instantiatio n of bean failed; nested exception is java.lang.NoSuchMethodError: org.apache.lo g4j.LogManager.getLoggerRepository()Lorg/apache/log4j/spi/LoggerRepository; at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb ject(AbstractBeanFactory.java:264) Truncated. see log file for complete stacktrace 这是属于什么问题啊?
myeclipse报错java.lang.ClassCastException: java.lang.Integer cannot be cast to org.model.Login
package org.model; public class Login { private Integer id; private String password; private String name; private boolean role; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getName() { return name; } public void setName(String name) { this.name = name; } public boolean isRole() { return role; } public void setRole(boolean role) { this.role = role; } } ``` ``` ``` ```
zookeeper java.lang.NoSuchMethodError异常
没找到问题所在 就是在myeclipse有出现 但在IDEA上就没有这个错误 错误如下: java.lang.NoSuchMethodError: org.apache.zookeeper.ZooKeeper.<init>(Ljava/lang/String;ILorg/apache/zookeeper/Watcher;Z)V at org.apache.curator.utils.DefaultZookeeperFactory.newZooKeeper(DefaultZookeeperFactory.java:29) at org.apache.curator.framework.imps.CuratorFrameworkImpl$2.newZooKeeper(CuratorFrameworkImpl.java:160) at org.apache.curator.HandleHolder$1.getZooKeeper(HandleHolder.java:94) at org.apache.curator.HandleHolder.getZooKeeper(HandleHolder.java:55) at org.apache.curator.ConnectionState.reset(ConnectionState.java:218) at org.apache.curator.ConnectionState.start(ConnectionState.java:102) at org.apache.curator.CuratorZookeeperClient.start(CuratorZookeeperClient.java:189) at org.apache.curator.framework.imps.CuratorFrameworkImpl.start(CuratorFrameworkImpl.java:263) at com.gome.clover.common.zk.ZKConnect.start(ZKConnect.java:55) at com.gome.clover.common.zk.ServerDict.init(ServerDict.java:51) at com.gome.clover.common.zk.ServerDict.<init>(ServerDict.java:45) at com.gome.clover.common.zk.ServerDict.<clinit>(ServerDict.java:41) at com.gome.clover.core.module.AbstractModuleScheduler.registerToZK(AbstractModuleScheduler.java:74) at com.gome.clover.core.module.ModuleSchedulerClient.startup(ModuleSchedulerClient.java:76) at com.gome.clover.server.module.SchedulerClientInitial.init(SchedulerClientInitial.java:77) at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5210) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5493) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662)
idea关于java.lang.ClassNotFoundException的问题
大致情况是这样的 公司项目之前用myeclipse,是Struts1+hibernate+spring+weblogic 我现在要用idea跑起来 结果错误如下: <2019-5-31 上午11时02分02秒 CST> <Error> <HTTP> <BEA-101163> <Could not load user defined listener: com.lbs.cp3.sysmanage.webcontroller.InitCodeListApplicationListener java.lang.ClassNotFoundException: com.lbs.cp3.sysmanage.webcontroller.InitCodeListApplicationListener at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:297) at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:270) at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:64) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) Truncated. see log file for complete stacktrace > 然后我去我的web.xml里面看了一下 ![图片说明](https://img-ask.csdn.net/upload/201905/31/1559289562_798328.png) 红圈里是我报错的listener,上下两个没报错,现在能判断的是,这个报错的listener是java文件(打包后也正常编译),而其他没报错的是jar包。 idea,weblogic,项目用的都是JDK1.7. 这是我的配置: ![图片说明](https://img-ask.csdn.net/upload/201905/31/1559290212_229938.png) 高亮处是没报错的引用的jar 我们项目用struts1.1,但是idea这边struts固定选择是1.2.不知道会不会是这个问题 ![图片说明](https://img-ask.csdn.net/upload/201905/31/1559290657_150722.png) 请大家给我一些排查思路
javadoc导出生成文档提示“javadoc: 错误 - java.lang.IllegalArgumentException”
myeclipse项目生成javadoc文档一直提示错误,如下提示信息: 正在加载源文件C:\Users\cainiao1_11\Workspaces\MyEclipse 2017 CI\ClassAndObject\src\cn\jbit\sch2\ScoreCalc.java... 正在构造 Javadoc 信息... 标准 Doclet 版本 1.8.0_45 正在构建所有程序包和类的树... 正在生成F:\MyEclipse\cn\jbit\sch2\ScoreCalc.html... java.lang.IllegalArgumentException at sun.net.www.ParseUtil.decode(ParseUtil.java:202) at sun.misc.URLClassPath$FileLoader.<init>(URLClassPath.java:1204) at sun.misc.URLClassPath$3.run(URLClassPath.java:525) at sun.misc.URLClassPath$3.run(URLClassPath.java:520) at java.security.AccessController.doPrivileged(Native Method) at sun.misc.URLClassPath.getLoader(URLClassPath.java:519) at sun.misc.URLClassPath.getLoader(URLClassPath.java:492) at sun.misc.URLClassPath.getNextLoader(URLClassPath.java:457) at sun.misc.URLClassPath.access$100(URLClassPath.java:64) at sun.misc.URLClassPath$1.next(URLClassPath.java:239) at sun.misc.URLClassPath$1.hasMoreElements(URLClassPath.java:250) at java.net.URLClassLoader$3$1.run(URLClassLoader.java:601) at java.net.URLClassLoader$3$1.run(URLClassLoader.java:599) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader$3.next(URLClassLoader.java:598) at java.net.URLClassLoader$3.hasMoreElements(URLClassLoader.java:623) at sun.misc.CompoundEnumeration.next(CompoundEnumeration.java:45) at sun.misc.CompoundEnumeration.hasMoreElements(CompoundEnumeration.java:54) at java.util.ServiceLoader$LazyIterator.hasNextService(ServiceLoader.java:354) at java.util.ServiceLoader$LazyIterator.hasNext(ServiceLoader.java:393) at java.util.ServiceLoader$1.hasNext(ServiceLoader.java:474) at javax.xml.parsers.FactoryFinder$1.run(FactoryFinder.java:293) at java.security.AccessController.doPrivileged(Native Method) at javax.xml.parsers.FactoryFinder.findServiceProvider(FactoryFinder.java:289) at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:267) at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:127) at com.sun.tools.doclets.internal.toolkit.builders.LayoutParser.parseXML(LayoutParser.java:89) at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.build(ClassBuilder.java:120) at com.sun.tools.doclets.formats.html.HtmlDoclet.generateClassFiles(HtmlDoclet.java:189) at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.generateClassFiles(AbstractDoclet.java:205) at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.generateClassFiles(AbstractDoclet.java:189) at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:137) at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.start(AbstractDoclet.java:82) at com.sun.tools.doclets.formats.html.HtmlDoclet.start(HtmlDoclet.java:80) at com.sun.tools.doclets.standard.Standard.start(Standard.java:39) 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:497) at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:310) at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:189) at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:366) at com.sun.tools.javadoc.Start.begin(Start.java:219) at com.sun.tools.javadoc.Start.begin(Start.java:205) at com.sun.tools.javadoc.Main.execute(Main.java:64) at com.sun.tools.javadoc.Main.main(Main.java:54) javadoc: 错误 - java.lang.IllegalArgumentException 1 个错误 按照网上的方法删除classpath,其他该设置的设置,还是一直报错,求大神帮忙解决
运行myeclipse时出现java.lang.NoClassDefFoundError的错误
我想获得网页的编码,在网上找了可以用chardet.jar中的方法实现,于是下载了它,导入我的工程中,然后用如下代码进行测试: import info.monitorenter.cpdetector.io.CodepageDetectorProxy; import info.monitorenter.cpdetector.io.HTMLCodepageDetector; import info.monitorenter.cpdetector.io.JChardetFacade; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; public class WebEncoding { private static CodepageDetectorProxy detector = CodepageDetectorProxy .getInstance(); static { detector.add(new HTMLCodepageDetector(false)); detector.add(JChardetFacade.getInstance()); } /** 测试用例 * @param args */ public static void main(String[] args) { WebEncoding web=new WebEncoding(); try { System.out.println("*******************"); System.out.println(web.getCharset("http://www.baidu.com/")); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** * @param strurl * 页面url地址,需要以 http://开始,例:http://www.pujia.com * @return * @throws IOException */ public String getCharset(String strurl) throws IOException { // 定义URL对象 URL url = new URL(strurl); // 获取http连接对象 HttpURLConnection urlConnection = (HttpURLConnection) url .openConnection(); ; urlConnection.connect(); // 网页编码 String strencoding = null; /** * 首先根据header信息,判断页面编码 */ // map存放的是header信息(url页面的头信息) Map<String, List<String>> map = urlConnection.getHeaderFields(); Set<String> keys = map.keySet(); Iterator<String> iterator = keys.iterator(); // 遍历,查找字符编码 String key = null; String tmp = null; while (iterator.hasNext()) { key = iterator.next(); tmp = map.get(key).toString().toLowerCase(); // 获取content-type charset if (key != null && key.equals("Content-Type")) { int m = tmp.indexOf("charset="); if (m != -1) { strencoding = tmp.substring(m + 8).replace("]", ""); return strencoding; } } } /** * 通过解析meta得到网页编码 */ // 获取网页源码(英文字符和数字不会乱码,所以可以得到正确<meta/>区域) StringBuffer sb = new StringBuffer(); String line; try { BufferedReader in = new BufferedReader(new InputStreamReader(url .openStream())); while ((line = in.readLine()) != null) { sb.append(line); } in.close(); } catch (Exception e) { // Report any errors that arise System.err.println(e); System.err .println("Usage: java HttpClient <URL> [<filename>]"); } String htmlcode = sb.toString(); // 解析html源码,取出<meta />区域,并取出charset String strbegin = "<meta"; String strend = ">"; String strtmp; int begin = htmlcode.indexOf(strbegin); int end = -1; int inttmp; while (begin > -1) { end = htmlcode.substring(begin).indexOf(strend); if (begin > -1 && end > -1) { strtmp = htmlcode.substring(begin, begin + end).toLowerCase(); inttmp = strtmp.indexOf("charset"); if (inttmp > -1) { strencoding = strtmp.substring(inttmp + 7, end).replace( "=", "").replace("/", "").replace("\"", "") .replace("\'", "").replace(" ", ""); return strencoding; } } htmlcode = htmlcode.substring(begin); begin = htmlcode.indexOf(strbegin); } /** * 分析字节得到网页编码 */ strencoding = getFileEncoding(url); // 设置默认网页字符编码 if (strencoding == null) { strencoding = "GBK"; } return strencoding; } /** * *<br> * 方法说明:通过网页内容识别网页编码 * *<br> * 输入参数:strUrl 网页链接; timeout 超时设置 * *<br> * 返回类型:网页编码 */ public static String getFileEncoding(URL url) { java.nio.charset.Charset charset = null; try { charset = detector.detectCodepage(url); } catch (Exception e) { System.out.println(e.getClass() + "分析" + "编码失败"); } if (charset != null) return charset.name(); return null; } } 可运行时总是出现java.lang.NoClassDefFoundError: org/mozilla/intl/chardet/nsICharsetDetectionObserver的错误 !!!!
有没有整过webService的, 客户端java.lang.IllegalStateException: Could not initialize Servi
有没有整过webService的, 客户端java.lang.IllegalStateException: Could not initialize Service. 这到底是个什么错????? [b]问题补充:[/b] 这个的具体错误: Exception in thread "main" java.lang.IllegalStateException: Could not initialize Service. at org.codehaus.xfire.jaxws.ServiceDelegate.<init>(ServiceDelegate.java:77) at org.codehaus.xfire.jaxws.Provider.createServiceDelegate(Provider.java:32) at javax.xml.ws.Service.<init>(Service.java:56) at com.demo.hw.server.Ibemain1.<init>(Ibemain1.java:47) at com.demo.hw.server.Ibemain_IbemainImplPort_Client.main(Ibemain_IbemainImplPort_Client.java:59) Caused by: java.lang.NoSuchMethodException: com.demo.hw.server.Ibemain1.getPortClassMap() at java.lang.Class.getMethod(Class.java:1605) at org.codehaus.xfire.jaxws.ServiceDelegate.<init>(ServiceDelegate.java:60) ... 4 more [b]问题补充:[/b] [b]Exception in thread "main" java.lang.IllegalStateException: Could not initialize Service.[/b] at org.codehaus.xfire.jaxws.ServiceDelegate.<init>(ServiceDelegate.java:77) at org.codehaus.xfire.jaxws.Provider.createServiceDelegate(Provider.java:32) at javax.xml.ws.Service.<init>(Service.java:56) at com.demo.hw.server.Ibemain1.<init>(Ibemain1.java:47) at com.demo.hw.server.Ibemain_IbemainImplPort_Client.main(Ibemain_IbemainImplPort_Client.java:59) [b]Caused by: java.lang.NoSuchMethodException: com.demo.hw.server.Ibemain1.getPortClassMap()[/b] at java.lang.Class.getMethod(Class.java:1605) at org.codehaus.xfire.jaxws.ServiceDelegate.<init>(ServiceDelegate.java:60) ... 4 more [b]问题补充:[/b] [color=red]1. wsdl有的,我用cxf当下客户端来,编译了一下,可以运行,没有报错。 2.测试成功后,我把这些包移到了myeclipse下(我的是7.1),我只修改了一下包名。之后运行了一下,就出现了上面我贴的错误,在百度,谷歌里也没找到答案。 3.我们项目里之前有人加了一个webservice的。[/color][size=large][/size] [b]问题补充:[/b] [color=red][size=large]这个 Ibemain1.getPortClassMap() 方法所在的类继承了Service类, 在这个类中,有几个方法调用了父类的构造方法, 我个人觉得可能是Service.在没有初始化成功的情况下,导致了没找到.getPortClassMap() 方法。为什么会出现 “[b]Exception in thread "main" java.lang.IllegalStateException: Could not initialize Service[/b]”我很迷惑~[/size][/color] [b]问题补充:[/b] wsdl地址 : http://123.234.20.38:8081/ibeserver/ws/first?wsdl [b]问题补充:[/b] [color=red]补充了一个方法,还是包这个错: Exception in thread "main" java.lang.IllegalStateException: Could not initialize Service. [/color][size=large][/size] [b]问题补充:[/b] 我觉得我已经找到问题愿原因了,我们项目中原有一个webServices的客户端,以前的那哥们是用xfrie来处理的,重新在myeclipse下建了一个项目后,能运行上面的两个错误都消失了。这里说明xfire有问题!以后使用这个要注意,最好不要用~! 最后,谢谢 andilyliao 兄,消耗了你这莫多的时间~!谢谢诶·
springmvc 实现文件下载 出现异常java.lang.OutOfMemoryError: Java heap space
网上找解决方案,一般都是tomcat中添加-Xms256m -Xms512m等配置,但是不行啊。 我的是MyEclipse里的tomcat。 下载20M(包括)以内的文件没问题,超过就会报异常,有什么解决办法吗? 还有是不是请求下载文件时,服务器会把文件全部装入内存再发过来,还是分成多个部分发送,超过内存大小的文件如何发送呢? ** *--异常信息* ** type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.OutOfMemoryError: Java heap space org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1259) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827) javax.servlet.http.HttpServlet.service(HttpServlet.java:690) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) root cause java.lang.OutOfMemoryError: Java heap space org.apache.commons.io.output.ByteArrayOutputStream.toByteArray(ByteArrayOutputStream.java:324) org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:361) org.apache.commons.io.FileUtils.readFileToByteArray(FileUtils.java:1360) com.ysm.ysite.controller.Test.fileDownload(Test.java:60) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:597) org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:440) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:428) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827) javax.servlet.http.HttpServlet.service(HttpServlet.java:690) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.
Myeclipse 2014部署SSH项目,Tomcat出现问题
``` org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/assistant]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1100) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1618) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744) Caused by: java.lang.NoClassDefFoundError: Lorg/hibernate/FlushMode; at java.lang.Class.getDeclaredFields0(Native Method) at java.lang.Class.privateGetDeclaredFields(Class.java:2397) at java.lang.Class.getDeclaredFields(Class.java:1806) at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:87) at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:261) at org.apache.catalina.startup.WebAnnotationSet.loadApplicationFilterAnnotations(WebAnnotationSet.java:110) at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:66) at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:405) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 10 more Caused by: java.lang.ClassNotFoundException: org.hibernate.FlushMode at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) ... 24 more 十一月 16, 2015 9:39:55 下午 org.apache.catalina.startup.HostConfig deployDirectory 严重: Error deploying web application directory E:\myworkplace\.metadata\.me_tcat7\webapps\assistant java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/assistant]] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1100) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1618) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744) ```
myeclipse java.lang.NoClassDefFoundError: jdk
使用myeclipse测试代码时出现错误 ![图片说明](https://img-ask.csdn.net/upload/201503/31/1427777337_205513.png) 楼主小菜一盘 求大侠帮忙 一下是环境变量配置 Java_home:D:\Program Files (x86)\Java\jdk1.6.0_37 classpath: .;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar path:C:\Windows;C:\Windows\system32;%JAVA_HOME%\bin
一个简单的jsp跳转servlet时出了问题 java.lang.IllegalAccessException(代码见附件)
[size=x-large]myeclipse的工程,跳转时报这样的错,[/size] [size=large]严重: Allocate exception for servlet LookUpUsers java.lang.IllegalAccessException: Class org.apache.catalina.core.DefaultInstanceManager can not access a member of class com.bank.LookUpUsersServlet with modifiers ""[/size] at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65) at java.lang.Class.newInstance0(Class.java:349) at java.lang.Class.newInstance(Class.java:308) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:119) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1062) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:813) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394) at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:284) at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:322) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1714) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) [size=large]像平时一样配置的web.xml,查了半天也没找到原因,谁能帮忙指点,谢过,[/size]
hibernate 出错 java.lang.ClassCastException
[size=medium]刚刚学hibernate ,运行时出现异常 Exception in thread "main" java.lang.ClassCastException: java.lang.String at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:377) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:112) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate( 下面是代码: [code="java"] public class TestHibernate { Configuration cfg; SessionFactory sf; Session session; public static void main(String[] args){ TestHibernate test = new TestHibernate(); test.work(); } public void work(){ cfg = new Configuration().configure(); sf = cfg.buildSessionFactory(); session = sf.openSession(); User user = new User(); user.setUserID("22"); user.setPassword("d"); user.setUsername("c"); session.beginTransaction(); session.save(user); session.getTransaction().commit(); } } [/code] pojo的代码: [code="java"] public class User implements Serializable { private String userID; private String username; private String password; public String getUserID() { return userID; } public void setUserID(String userID) { this.userID = userID; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } } [/code] [code="java"] <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Mapping file autogenerated by MyEclipse Persistence Tools --> <hibernate-mapping> <class name="vo.User" table="myproject1_t_user" catalog="myproject1"> <composite-id name="userID" class="vo.User"> <key-property name="userID" type="java.lang.String"> <column name="user_id" /> </key-property> <key-property name="username" type="java.lang.String"> <column name="username" /> </key-property> <key-property name="password" type="java.lang.String"> <column name="password" /> </key-property> </composite-id> </class> </hibernate-mapping> [/code][/size]
java.lang.ClassNotFoundException异常有哪些可能
新手一枚,写了个Struts2的demo,导入Struts2.3.4的jar包,用MyEclipse10自带的tomcat跑然后报错 严重: Exception starting filter struts2base01 java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExcuteFilter at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:249) at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3693) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4340) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:566) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) 2016-5-6 16:08:43 org.apache.catalina.core.StandardContext start 严重: Error filterStart 2016-5-6 16:08:43 org.apache.catalina.core.StandardContext start 严重: Context [/Struts2_base01] startup failed due to previous errors
请问java.lang.NullPoint问题出现的原因是什么?
各位朋友,希望你们帮我看看这个问题,我搜索了好多相关的资料还是没有找到一个实际方法来解决了这个问题的,使用测试类做测试都通过了,在MySQL数据库中都能插入信息,可是将其对应到RegisterAction类中之后就出问题了,一直没有解决,不知道是什么原因啊。困惑了2天了。 [color=red]Myelicpse6.0使用struts+hibernate在注册页面提交之后即出现下面的信息:[/color] type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: java.lang.NullPointerException org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462) javax.servlet.http.HttpServlet.service(HttpServlet.java:710) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) root cause java.lang.NullPointerException com.bbs.struts.action.RegisterAction.execute(RegisterAction.java:46) org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58) org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67) org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51) org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304) org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462) javax.servlet.http.HttpServlet.service(HttpServlet.java:710) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs. [color=red]下面是Myeclipse控制台输出的信息:[/color]%%%% Error Creating SessionFactory %%%% java.lang.SecurityException: class "org.apache.commons.collections.SequencedHashMap"'s signer information does not match signer information of other classes in the same package at java.lang.ClassLoader.checkCerts(ClassLoader.java:775) at java.lang.ClassLoader.preDefineClass(ClassLoader.java:487) at java.lang.ClassLoader.defineClass(ClassLoader.java:614) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1817) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:872) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1325) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) at org.hibernate.mapping.Table.<init>(Table.java:33) at org.hibernate.cfg.Mappings.addTable(Mappings.java:165) at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:299) at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:282) at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153) at org.hibernate.cfg.Configuration.add(Configuration.java:386) at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:427) at org.hibernate.cfg.Configuration.addResource(Configuration.java:482) at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1465) at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1433) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1414) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1390) at org.hibernate.cfg.Configuration.configure(Configuration.java:1310) at com.bbs.hibernate.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:69) at com.bbs.hibernate.HibernateSessionFactory.getSession(HibernateSessionFactory.java:53) at com.bbs.hibernate.BaseHibernateDAO.getSession(BaseHibernateDAO.java:13) at com.bbs.struts.action.RegisterAction.execute(RegisterAction.java:46) at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58) at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67) at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 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) 2008-8-4 21:40:10 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet action threw exception java.lang.NullPointerException at com.bbs.struts.action.RegisterAction.execute(RegisterAction.java:46) at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58) at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67) at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 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) [b]问题补充:[/b] 已经补充文件内容,谢谢大家再帮忙看看: ----------RegisterAction.java package com.yourcompany.struts.action; import hibernatedao.Bbsuser; import hibernatedao.BbsuserDAO; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.hibernate.Transaction; import com.yourcompany.struts.form.RegisterForm; public class RegisterAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { RegisterForm registerForm = (RegisterForm) form;// TODO Auto-generated method stub Bbsuser user =new Bbsuser(); user.setUsername(registerForm.getUsername()); user.setPassword(registerForm.getPassword()); //DAO对象 BbsuserDAO dao =new BbsuserDAO(); //开始事务 Transaction tran =dao.getSession().beginTransaction(); dao.save(user); //提交事务 tran.commit(); System.out.print("OK,All Pass!"); return mapping.findForward("success"); } } ----------------Bbsuser.hbm.xml <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Mapping file autogenerated by MyEclipse Persistence Tools --> <hibernate-mapping> <class name="hibernatedao.Bbsuser" table="bbsuser" catalog="mydb"> <id name="id" type="java.lang.Integer"> <column name="id" /> <generator class="increment" /> </id> <property name="username" type="java.lang.String"> <column name="username" length="200" not-null="true" /> </property> <property name="password" type="java.lang.String"> <column name="password" length="20" not-null="true" /> </property> <property name="age" type="java.lang.Integer"> <column name="age" /> </property> </class> </hibernate-mapping> --------------------web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>3</param-value> </init-param> <init-param> <param-name>detail</param-name> <param-value>3</param-value> </init-param> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> ---------------------struts-config.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"> <struts-config> <data-sources /> <form-beans > <form-bean name="registerForm" type="com.yourcompany.struts.form.RegisterForm" /> </form-beans> <global-exceptions /> <global-forwards /> <action-mappings > <action attribute="registerForm" input="/form/register.jsp" name="registerForm" path="/register" scope="request" type="com.yourcompany.struts.action.RegisterAction"> <forward name="failed" path="/failed.jsp" /> <forward name="success" path="/success.jsp" /> </action> </action-mappings> <message-resources parameter="com.yourcompany.struts.ApplicationResources" /> </struts-config>
MyEclipse8.5 连接MYSQL5.5数据库的问题
<p>您好!我用MyEclipse8.5 + MySQL5.5 + win7环境下编写程序测试连接数据库的程序。但是出现以下问题:<br>java.lang.ClassNotFoundException: com.MySQL.jdbc.Driver<br> at java.net.URLClassLoader$1.run(URLClassLoader.java:202)<br> at java.security.AccessController.doPrivileged(Native Method)<br> at java.net.URLClassLoader.findClass(URLClassLoader.java:190)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)<br> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:248)<br> at java.lang.Class.forName0(Native Method)<br> at java.lang.Class.forName(Class.java:169)<br> at MySQL.jdbcTest1.initJdbc(jdbcTest1.java:10)<br> at MySQL.jdbcTest1.getConnection(jdbcTest1.java:17)<br> at MySQL.jdbcTest1.testQuery(jdbcTest1.java:29)<br> at MySQL.jdbcTest1.main(jdbcTest1.java:148)<br>java.lang.ClassNotFoundException: com.MySQL.jdbc.Driver<br> at java.net.URLClassLoader$1.run(URLClassLoader.java:202)<br> at java.security.AccessController.doPrivileged(Native Method)<br> at java.net.URLClassLoader.findClass(URLClassLoader.java:190)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)<br> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:248)<br> at java.lang.Class.forName0(Native Method)<br> at java.lang.Class.forName(Class.java:169)<br> at MySQL.jdbcTest1.initJdbc(jdbcTest1.java:10)<br> at MySQL.jdbcTest1.getConnection(jdbcTest1.java:17)<br> at MySQL.jdbcTest1.testInsert(jdbcTest1.java:62)<br> at MySQL.jdbcTest1.main(jdbcTest1.java:149)<br>java.lang.ClassNotFoundException: com.MySQL.jdbc.Driver<br> at java.net.URLClassLoader$1.run(URLClassLoader.java:202)<br> at java.security.AccessController.doPrivileged(Native Method)<br> at java.net.URLClassLoader.findClass(URLClassLoader.java:190)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)<br> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:248)<br> at java.lang.Class.forName0(Native Method)<br> at java.lang.Class.forName(Class.java:169)<br> at MySQL.jdbcTest1.initJdbc(jdbcTest1.java:10)<br> at MySQL.jdbcTest1.getConnection(jdbcTest1.java:17)<br> at MySQL.jdbcTest1.testQuery(jdbcTest1.java:29)<br> at MySQL.jdbcTest1.main(jdbcTest1.java:150)<br>java.lang.ClassNotFoundException: com.MySQL.jdbc.Driver<br> at java.net.URLClassLoader$1.run(URLClassLoader.java:202)<br> at java.security.AccessController.doPrivileged(Native Method)<br> at java.net.URLClassLoader.findClass(URLClassLoader.java:190)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)<br> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:248)<br> at java.lang.Class.forName0(Native Method)<br> at java.lang.Class.forName(Class.java:169)<br> at MySQL.jdbcTest1.initJdbc(jdbcTest1.java:10)<br> at MySQL.jdbcTest1.getConnection(jdbcTest1.java:17)<br> at MySQL.jdbcTest1.testUpdate(jdbcTest1.java:98)<br> at MySQL.jdbcTest1.main(jdbcTest1.java:151)<br>java.lang.ClassNotFoundException: com.MySQL.jdbc.Driver<br> at java.net.URLClassLoader$1.run(URLClassLoader.java:202)<br> at java.security.AccessController.doPrivileged(Native Method)<br> at java.net.URLClassLoader.findClass(URLClassLoader.java:190)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)<br> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:248)<br> at java.lang.Class.forName0(Native Method)<br> at java.lang.Class.forName(Class.java:169)<br> at MySQL.jdbcTest1.initJdbc(jdbcTest1.java:10)<br> at MySQL.jdbcTest1.getConnection(jdbcTest1.java:17)<br> at MySQL.jdbcTest1.testQuery(jdbcTest1.java:29)<br> at MySQL.jdbcTest1.main(jdbcTest1.java:152)<br>java.lang.ClassNotFoundException: com.MySQL.jdbc.Driver<br> at java.net.URLClassLoader$1.run(URLClassLoader.java:202)<br> at java.security.AccessController.doPrivileged(Native Method)<br> at java.net.URLClassLoader.findClass(URLClassLoader.java:190)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)<br> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:248)<br> at java.lang.Class.forName0(Native Method)<br> at java.lang.Class.forName(Class.java:169)<br> at MySQL.jdbcTest1.initJdbc(jdbcTest1.java:10)<br> at MySQL.jdbcTest1.getConnection(jdbcTest1.java:17)<br> at MySQL.jdbcTest1.testDelete(jdbcTest1.java:123)<br> at MySQL.jdbcTest1.main(jdbcTest1.java:153)<br>java.lang.ClassNotFoundException: com.MySQL.jdbc.Driver<br> at java.net.URLClassLoader$1.run(URLClassLoader.java:202)<br> at java.security.AccessController.doPrivileged(Native Method)<br> at java.net.URLClassLoader.findClass(URLClassLoader.java:190)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)<br> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:248)<br> at java.lang.Class.forName0(Native Method)<br> at java.lang.Class.forName(Class.java:169)<br> at MySQL.jdbcTest1.initJdbc(jdbcTest1.java:10)<br> at MySQL.jdbcTest1.getConnection(jdbcTest1.java:17)<br> at MySQL.jdbcTest1.testQuery(jdbcTest1.java:29)<br> at MySQL.jdbcTest1.main(jdbcTest1.java:154)<br>用mysql-connector-java-5.1.20-bin的jar驱动</p> <p>程序代码如下:package MySQL;</p> <p><br>import java.sql.*;<br>public class jdbcTest1 {</p> <p> boolean bInited=false;<br> //加载驱动<br> public void initJdbc() throws ClassNotFoundException{<br> Class.forName("com.MySQL.jdbc.Driver");<br> bInited=true;<br> }<br> //获得数据库连接<br> public Connection getConnection() throws ClassNotFoundException,<br> SQLException{<br> if(!bInited)<br> initJdbc();<br> return DriverManager<br> .getConnection("jdbc:MySQL://localhost:3306/mytest?user=root&amp;password" +<br> "=mjf10086&amp;useUnicode=true&amp;charaterEncoding=gb2312");<br> //注意,这里的字符集与数据库的设置一致<br> }<br><br> public void testQuery(){<br> Connection conn=null;<br> Statement smt = null;<br> ResultSet rs=null;<br> try{<br> conn = getConnection();<br> smt = conn.createStatement();<br> String sql = "select*from table1";<br> rs = smt.executeQuery(sql);<br> while(rs.next()){<br> System.out.println("id:"+rs.getInt("_id")+"username:"<br> +rs.getString("_username")+"password:"<br> +rs.getString("_password")+"desc:"<br> +rs.getString("_desc"));<br> }<br> }catch(SQLException e){<br> e.printStackTrace();<br> }catch(Exception e){<br> e.printStackTrace();<br> }finally{<br> try{<br> if(rs!=null)<br> rs.close();<br> if(smt!=null)<br> smt.close();<br> if(conn!=null)<br> conn.close();<br><br> }catch(Exception e){<br> e.printStackTrace();<br> }<br> }<br> }<br><br> public void testInsert(){<br> Connection conn = null;<br> Statement smt = null;<br> try{<br> conn = getConnection();<br> smt = conn.createStatement();<br> smt<br> .execute("insert into table1(_username,_password,_desc)values" +<br> "('马拉多纳','10','阿根廷足球运动员')");<br> smt<br> .execute("insert into table1(_username,_password,_desc)values" +<br> "('坎通纳','7','法国足球运动员')");<br> smt<br> .execute("insert into table1(_username,__password,_desc)values" +<br> "('罗马里奥','11','巴西足球运动员')");<br> smt<br> .execute("insert into table1(_username,_password,_desc)values" +<br> "('古利特','8','荷兰足球运动员')");<br><br> }catch(SQLException e){<br> e.printStackTrace();<br> }catch(Exception e){<br> e.printStackTrace();<br> }finally{<br> try{<br> if(smt !=null)<br> smt.close();<br> if(conn !=null)<br> conn.close();<br><br> }catch(Exception e){<br> e.printStackTrace();<br> }<br> }<br> }<br><br> public void testUpdate(){<br> Connection conn = null;<br> Statement smt = null;<br> try{<br> conn = getConnection();<br> smt = conn.createStatement();<br> smt<br> .execute("update table1 set _desc '阿根廷足球球员,一代球王'" +<br> "where _username='马拉多纳'");<br> }catch(SQLException e){<br> e.printStackTrace();<br> }catch(Exception e){<br> e.printStackTrace();<br> }finally{<br> try{<br> if(smt!=null)<br> smt.close();<br> if(conn!=null)<br> conn.close();<br> }catch(Exception e){<br> e.printStackTrace();<br> }<br> }<br> }<br><br> public void testDelete(){<br> Connection conn = null;<br> Statement smt = null;<br> try{<br> conn = getConnection();<br> smt = conn.createStatement();<br> smt.execute("delete from table1 where _username = '马拉多纳'");<br> smt.execute("delete from table1 where _username = '坎通纳'");<br> smt.execute("delete from table1 where _username = '罗马里奥'");<br> smt.execute("delete from table1 where _username = '古利特'");</p> <p> }catch(SQLException e){<br> e.printStackTrace();<br> }catch(Exception e){<br> e.printStackTrace();<br> }finally{<br> try{<br> if(smt !=null)<br> smt.close();<br> if(conn !=null)<br> conn.close();<br> }catch(Exception e){<br> e.printStackTrace();<br> }<br> }<br> }<br><br> public static void main(String[] args){<br> jdbcTest1 jt1 = new jdbcTest1();<br> jt1.testQuery();<br> jt1.testInsert();<br> jt1.testQuery();<br> jt1.testUpdate();<br> jt1.testQuery();<br> jt1.testDelete();<br> jt1.testQuery();<br> }<br>}</p>
相见恨晚的超实用网站
搞学习 知乎:www.zhihu.com 简答题:http://www.jiandati.com/ 网易公开课:https://open.163.com/ted/ 网易云课堂:https://study.163.com/ 中国大学MOOC:www.icourse163.org 网易云课堂:study.163.com 哔哩哔哩弹幕网:www.bilibili.com 我要自学网:www.51zxw
花了20分钟,给女朋友们写了一个web版群聊程序
参考博客 [1]https://www.byteslounge.com/tutorials/java-ee-html5-websocket-example
爬虫福利二 之 妹子图网MM批量下载
爬虫福利一:27报网MM批量下载    点击 看了本文,相信大家对爬虫一定会产生强烈的兴趣,激励自己去学习爬虫,在这里提前祝:大家学有所成! 目标网站:妹子图网 环境:Python3.x 相关第三方模块:requests、beautifulsoup4 Re:各位在测试时只需要将代码里的变量 path 指定为你当前系统要保存的路径,使用 python xxx.py 或IDE运行即可。
字节跳动视频编解码面经
引言 本文主要是记录一下面试字节跳动的经历。 三四月份投了字节跳动的实习(图形图像岗位),然后hr打电话过来问了一下会不会opengl,c++,shador,当时只会一点c++,其他两个都不会,也就直接被拒了。 七月初内推了字节跳动的提前批,因为内推没有具体的岗位,hr又打电话问要不要考虑一下图形图像岗,我说实习投过这个岗位不合适,不会opengl和shador,然后hr就说秋招更看重基础。我当时
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 顺便拉下票,我在参加csdn博客之星竞选,欢迎投票支持,每个QQ或者微信每天都可以投5票,扫二维码即可,http://m234140.nofollow.ax.
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
Python 基础(一):入门必备知识
目录1 标识符2 关键字3 引号4 编码5 输入输出6 缩进7 多行8 注释9 数据类型10 运算符10.1 常用运算符10.2 运算符优先级 1 标识符 标识符是编程时使用的名字,用于给变量、函数、语句块等命名,Python 中标识符由字母、数字、下划线组成,不能以数字开头,区分大小写。 以下划线开头的标识符有特殊含义,单下划线开头的标识符,如:_xxx ,表示不能直接访问的类属性,需通过类提供
这30个CSS选择器,你必须熟记(上)
关注前端达人,与你共同进步CSS的魅力就是让我们前端工程师像设计师一样进行网页的设计,我们能轻而易举的改变颜色、布局、制作出漂亮的影音效果等等,我们只需要改几行代码,不需...
国产开源API网关项目进入Apache孵化器:APISIX
点击蓝色“程序猿DD”关注我回复“资源”获取独家整理的学习资料!近日,又有一个开源项目加入了这个Java开源界大名鼎鼎的Apache基金会,开始进行孵化器。项目名称:AP...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 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)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
编写Spring MVC控制器的14个技巧
本期目录 1.使用@Controller构造型 2.实现控制器接口 3.扩展AbstractController类 4.为处理程序方法指定URL映射 5.为处理程序方法指定HTTP请求方法 6.将请求参数映射到处理程序方法 7.返回模型和视图 8.将对象放入模型 9.处理程序方法中的重定向 10.处理表格提交和表格验证 11.处理文件上传 12.在控制器中自动装配业务类 ...
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹
面试官:你连RESTful都不知道我怎么敢要你?
面试官:了解RESTful吗? 我:听说过。 面试官:那什么是RESTful? 我:就是用起来很规范,挺好的 面试官:是RESTful挺好的,还是自我感觉挺好的 我:都挺好的。 面试官:… 把门关上。 我:… 要干嘛?先关上再说。 面试官:我说出去把门关上。 我:what ?,夺门而去 文章目录01 前言02 RESTful的来源03 RESTful6大原则1. C-S架构2. 无状态3.统一的接
求小姐姐抠图竟遭白眼?痛定思痛,我决定用 Python 自力更生!
点击蓝色“Python空间”关注我丫加个“星标”,每天一起快乐的学习大家好,我是 Rocky0429,一个刚恰完午饭,正在用刷网页浪费生命的蒟蒻...一堆堆无聊八卦信息的网页内容慢慢使我的双眼模糊,一个哈欠打出了三斤老泪,就在此时我看到了一张图片:是谁!是谁把我女朋友的照片放出来的!awsl!太好看了叭...等等,那个背景上的一堆鬼画符是什么鬼?!真是看不下去!叔叔婶婶能忍,隔壁老王的三姨妈的四表...
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
致 Python 初学者
欢迎来到“Python进阶”专栏!来到这里的每一位同学,应该大致上学习了很多 Python 的基础知识,正在努力成长的过程中。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言,从2009年开始单一使用 python 应对所有的开发工作,直至今天。回顾自己的学习过程,也曾经遇到过无数的困难,也曾经迷茫过、困惑过。开办这个专栏,正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
相关热词 c# plc s1200 c#里氏转换原则 c# 主界面 c# do loop c#存为组套 模板 c# 停掉协程 c# rgb 读取图片 c# 图片颜色调整 最快 c#多张图片上传 c#密封类与密封方法
立即提问