导入Java项目,xml文件中出现<#List></#List>一直报这个错误 The content of elements must consist of well-formed character data or markup

导入Java项目,xml文件中出现<#list></#list>这种结构的一直报错误

错误信息如下:
The content of elements must consist of well-formed character data or markup

报错的XML代码如下结构如下
<#list rsBelieverStatsList as rsBelieverStatsBean>。。。。。
</#list>

实在没有头绪,请各位帮下忙

3个回答

完整的xml文件提供下

找一个在线校验 XML 的工具校验一下就知道 XML 中不允许 # 字符出现的,把所有涉及到 # 的字符都去掉。

XML文件是不允许<这里面有特殊字符>

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
ssm框架demo遇到的问题
各位老哥们大家好,我是一名大二学生,自学Java一年半了,进步很慢,在ssm框架上遇到了问题,认识的人少,这个问题没人指点我,我很难再往后学习。 下面描述一下我遇到的问题吧:我比较抵触写jsp,所以从javaweb开始就尝试前后端分离,在学习ssm框架时,讲师用的都是jsp,我以为只要把springmvc的视图解析器中suffix配置成.html就行了,事情却没那么简单,项目一运行就报404,按理应该默认去找index.html,但是却直接报错,希望老哥们给我分析一下我哪里有错误。希望前辈能指导一下,谢谢了 ## 1:创建项目,我用的是IDEA,创建时选择的是Maven的webapp骨架。 ## 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 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <packaging>war</packaging> <name>register</name> <groupId>xyz.peterparker</groupId> <artifactId>register</artifactId> <version>1.0-SNAPSHOT</version> <build> <plugins> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <version>6.1.7</version> <configuration> <connectors> <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> <port>8888</port> <maxIdleTime>30000</maxIdleTime> </connector> </connectors> <webAppSourceDirectory>${project.build.directory}/${pom.artifactId}-${pom.version} </webAppSourceDirectory> <contextPath>/</contextPath> </configuration> </plugin> </plugins> </build> <properties> <spring.version>5.2.1.RELEASE</spring.version> <slf4j.version>1.6.6</slf4j.version> <log4j.version>1.2.12</log4j.version> <mybatis.version>3.4.5</mybatis.version> </properties> <dependencies> <!--dependency> <groupId>xyz.peterparker</groupId> <artifactId>[the artifact id of the block to be mounted]</artifactId> <version>1.0-SNAPSHOT</version> </dependency--> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.6.8</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <!-- log start --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${slf4j.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${slf4j.version}</version> </dependency> <!-- log end --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.3.0</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>${mybatis.version}</version> </dependency> <dependency> <groupId>c3p0</groupId> <artifactId>c3p0</artifactId> <version>0.9.1.2</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>javax.annotation</groupId> <artifactId>jsr250-api</artifactId> <version>1.0</version> </dependency> <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.16</version> </dependency> </dependencies> </project> ``` ## 3:创建包结构 ![图片说明](https://img-ask.csdn.net/upload/202002/19/1582083667_469404.png) ## 4:编写web.xml ``` <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <!-- 更改applicationContext的默认位置 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <!-- 配置监听器 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> </listener> <!-- 配置前端控制器 --> <servlet> <servlet-name>dispatcherServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springmvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcherServlet</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> <!-- 配置解决中文乱码的过滤器 --> <filter> <filter-name>characterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>characterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> </web-app> ``` ## 5:编写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:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <!-- 扫描service和dao --> <context:component-scan base-package="dao" /> <context:component-scan base-package="service" /> <!-- 引入dataSource.properties --> <context:property-placeholder location="classpath:dataSource.properties" /> <!-- 配置数据库连接池 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${driverClass}" /> <property name="jdbcUrl" value="${jdbcUrl}" /> <property name="user" value="${user}" /> <property name="password" value="${password}" /> </bean> <!-- 配置SqlSessionFactoryBean --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> </bean> <!-- 配置扫描dao --> <bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="dao" /> </bean> <!-- 配置声明式事务管理 --> <bean id="dataSourceTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <tx:annotation-driven transaction-manager="dataSourceTransactionManager" /> </beans> ``` ## 6:编写dataSource.properties ``` driverClass=com.mysql.cj.jdbc.Driver jdbcUrl=jdbc:mysql://localhost/user?useSSL=false&serverTimezone=Asia/Shanghai user=root password=rhw19990625 ``` ## 7:编写springmvc.xml ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- 配置扫描controller --> <context:component-scan base-package="controller" /> <!-- 配置视图解析器 --> <bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="pages" /> <property name="suffix" value=".html" /> <property name="contentType" value="text/html" /> </bean> <mvc:annotation-driven /> <mvc:default-servlet-handler /> <aop:aspectj-autoproxy proxy-target-class="true"/> </beans> ``` ## 8:编写User实体类 ``` package domain; import java.io.Serializable; public class User implements Serializable { private String username; private Integer tel; private String password; public User() { } public User(String username, Integer tel, String password) { this.username = username; this.tel = tel; this.password = password; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public Integer getTel() { return tel; } public void setTel(Integer tel) { this.tel = tel; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } } ``` ## 9:编写dao层接口UserDao ``` package dao; import domain.User; import org.apache.ibatis.annotations.Insert; import org.springframework.stereotype.Repository; @Repository public interface UserDao { @Insert("insert into user values(#{username},#{tel},#{password})") void insert(User user); } ``` ## 10:编写service层接口UserService ``` package service; import domain.User; public interface UserService { void insert(User user); } ``` ## 11:编写service层实现类UserServiceImpl ``` package service.impl; import dao.UserDao; import domain.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import service.UserService; @Service public class UserServiceImpl implements UserService { @Autowired private UserDao userDao; public void insert(User user) { userDao.insert(user); } } ``` ## 12:编写Controller类UserController ``` package controller; import com.sun.codemodel.internal.JMethod; import domain.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import service.UserService; @Controller @RequestMapping("user") public class UserController { @Autowired private UserService userService; @ResponseBody @RequestMapping(value = "register" ,method = RequestMethod.POST) public String insert(User user){ userService.insert(user); return "success"; } } ``` ## 13:编写index.html ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Register</title> </head> <body> <form action="/user/register" method="post"> <input type="text" name="username"> <input type="text" name="tel"> <input type="password" name="password"> <input type="submit"> </form> </body> </html> ``` ## 14:编写pages文件夹下的success.html ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Success</title> </head> <body> <h3>Success!...</h3> </body> </html> ```
这种错怎么解决突然报的404 导入之前的项目或者都复制过来都不报错 新建一个jsp页面就报404
7月 24, 2019 9:10:26 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Server.服务器版本: Apache Tomcat/9.0.19 7月 24, 2019 9:10:26 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Server.构建: Apr 12 2019 14:22:48 UTC 7月 24, 2019 9:10:26 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Server version number: 9.0.19.0 7月 24, 2019 9:10:26 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: OS Name: Windows 10 7月 24, 2019 9:10:26 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: OS.版本: 10.0 7月 24, 2019 9:10:26 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 结.造: amd64 7月 24, 2019 9:10:26 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Java 环境变量: C:\Program Files\Java\jre-9.0.4 7月 24, 2019 9:10:26 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: JVM 版本: 9.0.4+11 7月 24, 2019 9:10:26 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: JVM.供应商: Oracle Corporation 7月 24, 2019 9:10:26 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: CATALINA_BASE: E:\mybatis\.metadata\.plugins\org.eclipse.wst.server.core\tmp0 7月 24, 2019 9:10:26 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: CATALINA_HOME: E:\mytomcat\apache-tomcat-9.0.19 7月 24, 2019 9:10:26 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Dcatalina.base=E:\mybatis\.metadata\.plugins\org.eclipse.wst.server.core\tmp0 7月 24, 2019 9:10:26 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Dcatalina.home=E:\mytomcat\apache-tomcat-9.0.19 7月 24, 2019 9:10:26 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Dwtp.deploy=E:\mybatis\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps 7月 24, 2019 9:10:26 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Dfile.encoding=UTF-8 7月 24, 2019 9:10:26 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent 信息: Loaded APR based Apache Tomcat Native library [1.2.21] using APR version [1.6.5]. 7月 24, 2019 9:10:26 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent 信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true]. 7月 24, 2019 9:10:26 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent 信息: APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true] 7月 24, 2019 9:10:26 下午 org.apache.catalina.core.AprLifecycleListener initializeSSL 信息: OpenSSL successfully initialized [OpenSSL 1.1.1a 20 Nov 2018] 7月 24, 2019 9:10:26 下午 org.apache.coyote.AbstractProtocol init 信息: 初始化协议处理器 ["http-nio-8080"] 7月 24, 2019 9:10:27 下午 org.apache.coyote.AbstractProtocol init 信息: 初始化协议处理器 ["ajp-nio-8009"] 7月 24, 2019 9:10:27 下午 org.apache.catalina.startup.Catalina load 信息: 服务器在[1,274]毫秒内初始化 7月 24, 2019 9:10:27 下午 org.apache.catalina.core.StandardService startInternal 信息: Starting service [Catalina] 7月 24, 2019 9:10:27 下午 org.apache.catalina.core.StandardEngine startInternal 信息: Starting Servlet engine: [Apache Tomcat/9.0.19] 7月 24, 2019 9:10:27 下午 org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom 警告: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [171] milliseconds. 7月 24, 2019 9:10:32 下午 org.apache.catalina.core.ApplicationContext log 信息: No Spring WebApplicationInitializer types detected on classpath 7月 24, 2019 9:10:33 下午 org.apache.jasper.servlet.TldScanner scanJars 信息: 至少有一个JAR被扫描用于TLD但尚未包含TLD。 为此记录器启用调试日志记录,以获取已扫描但未在其中找到TLD的完整JAR列表。 在扫描期间跳过不需要的JAR可以缩短启动时间和JSP编译时间。 7月 24, 2019 9:10:33 下午 org.apache.catalina.core.ApplicationContext log 信息: Initializing Spring root WebApplicationContext 7月 24, 2019 9:13:04 下午 org.apache.ibatis.mapping.VendorDatabaseIdProvider getDatabaseId 严重: Could not get a databaseId from dataSource java.sql.SQLException: Connections could not be acquired from the underlying database! at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:529) at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128) at org.apache.ibatis.mapping.VendorDatabaseIdProvider.getDatabaseProductName(VendorDatabaseIdProvider.java:76) at org.apache.ibatis.mapping.VendorDatabaseIdProvider.getDatabaseName(VendorDatabaseIdProvider.java:61) at org.apache.ibatis.mapping.VendorDatabaseIdProvider.getDatabaseId(VendorDatabaseIdProvider.java:49) at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:395) at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:295) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4682) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5150) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367) at java.base/java.util.concurrent.FutureTask.run(Unknown Source) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(Unknown Source) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367) at java.base/java.util.concurrent.FutureTask.run(Unknown Source) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(Unknown Source) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:423) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.Catalina.start(Catalina.java:633) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492) Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source. at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319) at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557) at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525) ... 50 more WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.apache.ibatis.reflection.Reflector (file:/E:/mybatis/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/aa/WEB-INF/lib/mybatis-3.2.2.jar) to method java.lang.Object.finalize() WARNING: Please consider reporting this to the maintainers of org.apache.ibatis.reflection.Reflector WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 7月 24, 2019 9:13:05 下午 org.apache.catalina.core.ApplicationContext log 信息: Initializing Spring FrameworkServlet 'springmvc' 7月 24, 2019 9:13:06 下午 org.apache.coyote.AbstractProtocol start 信息: 开始协议处理句柄["http-nio-8080"] 7月 24, 2019 9:13:06 下午 org.apache.coyote.AbstractProtocol start 信息: 开始协议处理句柄["ajp-nio-8009"] 7月 24, 2019 9:13:06 下午 org.apache.catalina.startup.Catalina start 信息: Server startup in [159,538] milliseconds web配置文件 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>SpringMybatisOa</display-name> <!-- dwr --> <servlet> <servlet-name>dwr_invoker</servlet-name> <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class> <init-param> <param-name>crossDomainSessionSecurity</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>true</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>dwr_invoker</servlet-name> <url-pattern>/dwre/*</url-pattern> </servlet-mapping> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springconfig/*.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>springmvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springmvc</servlet-name> <url-pattern>*.action</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> </web-app> springmvc配置 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <mvc:annotation-driven/><!-- 启动注解方式的mvc --> <context:component-scan base-package="action"/><!-- 扫描该包下所有类加载到容器 --> <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/"/> <property name="suffix" value=".jsp"/> </bean> </beans> spring配置 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations" value="classpath:jdbc.properties"></property> </bean> <bean id="ds" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="${driverClass}" /> <property name="jdbcUrl" value="${url}" /> <property name="user" value="${userName}" /> <property name="password" value="${passWord}" /> </bean> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="ds" /> </bean> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="ds" /> <!-- 自动扫描mapping.xml文件 --> <property name="mapperLocations" value="classpath:dao/*.xml"></property> </bean> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/> <property name="basePackage" value="dao" /> </bean> <tx:annotation-driven transaction-manager="transactionManager"/> <context:component-scan base-package="biz.impl"/> </beans> 在线等 急!!!
ssm框架整合CXF框架,接口调用报org.apache.cxf.jaxrs.utils.JAXRSUtils.logMessageHandlerProblem No message body reader has been found for class com.fox.entity.UserVO, ContentType: application/json
![图片说明](https://img-ask.csdn.net/upload/201912/01/1575182347_905130.png) 实在找不到什么原因了,请大神帮帮忙指点下,刚搭的环境,初来没有币可悬赏,谢谢 ``` POM.xml <!--CXF web service框架依赖--> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-core</artifactId> <version>3.1.11</version> </dependency> <!-- cxf 进行rs开发 必须导入 --> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxrs</artifactId> <version>3.1.11</version> </dependency> <!-- 客户端 --> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-client</artifactId> <version>3.1.11</version> </dependency> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-jaxrs</artifactId> <version>1.9.13</version> </dependency> <!--<dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-extension-providers</artifactId> <version>3.1.17</version> </dependency>--> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> <version>3.1.11</version> </dependency> web.xml <!--设置配置文件的路径--> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml,classpath:springMVC.xml,classpath:com/fox/services/resources/services-config.xml</param-value> </context-param> <!--配置Spring的监听器,默认只加载WEB-INF目录下的applicationContext.xml配置文件--> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <!--配置前端控制器--> <servlet> <servlet-name>dispatcherServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <!--加载springmvc.xml配置文件--> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springMVC.xml</param-value> </init-param> <!--启动服务器,创建该servlet--> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcherServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <servlet> <servlet-name>CXFServlet</servlet-name> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> <!--<load-on-startup>1</load-on-startup>--> <!--<init-param> <param-name>config-location</param-name> <param-value>classpath*:services-config.xml</param-value> </init-param>--> </servlet> <servlet-mapping> <servlet-name>CXFServlet</servlet-name> <url-pattern>/webservice/*</url-pattern> </servlet-mapping> <!--解决中文乱码的过滤器--> <filter> <filter-name>characterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>characterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> ``` 接口 package com.fox.services; import com.fox.entity.UserVO; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.util.List; @Path("/user") @Produces({MediaType.APPLICATION_JSON}) public interface IUser { @POST @Path("/queryUser") @Consumes({MediaType.APPLICATION_JSON}) public List<UserVO> queryUser(UserVO userVO) throws Exception; }
struts2导入多个xml,第一个没问题,第二个报错
struts.xml [code="xml"]<?xml version="1.0" encoding="UTF-8"?> <!-- 指定Struts 2配置文件的DTD信息 --> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <!-- Struts 2配置文件的根元素 --> <struts> <!-- struts2 默认配置文件,必须加进来 有这里看出,当前文件的路径是跟路径下classes路径,所以其他的文件要从classes这个路径开始找 --> <include file="struts-plugin.xml" /> <include file="struts-default.xml" /> <!-- 自己添加的配置文件 --> <include file="../struts2/struts_user.xml" /> <include file="../struts2/struts_sign.xml" /> </struts>[/code] struts_user.xml [code="xml"]<?xml version="1.0" encoding="UTF-8"?> <!-- 指定Struts 2配置文件的DTD信息 --> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <!-- Struts 2配置文件的根元素 --> <struts> <!-- 配置了系列常量 --> <constant name="struts.i18n.encoding" value="UTF-8" /> <constant name="struts.devMode" value="true" /> <package name="Aberic" extends="struts-default"> <!-- 定义处理用户请求的Action --> <action name="login" class="loginAction"> <!-- 为两个逻辑视图配置视图页面 --> <result name="error">/error.jsp</result> <result name="success">/admin/admin.jsp</result> <interceptor-ref name="sessionstack" /> </action> </package> </struts>[/code] struts_sign.xml [code="xml"]<?xml version="1.0" encoding="UTF-8"?> <!-- 指定Struts 2配置文件的DTD信息 --> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <!-- Struts 2配置文件的根元素 --> <struts> <!-- 配置了系列常量 --> <constant name="struts.i18n.encoding" value="UTF-8" /> <constant name="struts.devMode" value="true" /> <package name="Aberic" extends="struts-default"> <!-- 定义处理用户请求的Action --> <action name="sign" class="PhoneSignAction"> <!-- 因为仅提供手机签到,故不配置任何视图 --> <result type="stream"> <param name="contentType">text/html</param> <param name="inputName">inputStream</param> </result> </action> </package> </struts>[/code] web.xml [code="xml"]<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <servlet> <servlet-name>proxoolServletConfigurator</servlet-name> <servlet-class> org.logicalcobwebs.proxool.configuration.ServletConfigurator </servlet-class> <init-param> <param-name>xmlFile</param-name> <param-value>WEB-INF/proxool.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/log4j.properties</param-value> </context-param> <context-param> <param-name>log4jRefreshInterval</param-name> <param-value>60000</param-value> </context-param> <listener> <listener-class> org.springframework.web.util.Log4jConfigListener </listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> <init-param> <param-name>config</param-name> <param-value>struts-default.xml,struts-plugin.xml,../struts2/struts.xml</param-value> </init-param> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <session-config> <session-timeout>30</session-timeout> </session-config> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>[/code] 因为我配的有spring,所以action中class没有指定类而是交给spring管理了 现在有一个奇怪的问题就是当我把../struts2/struts_user.xml先include进去的时候,就能够成功加载进去,登陆操作无误 当我把../struts2/struts_sign.xml放在../struts2/struts_user.xml上面的时候,就成了签到成功,但登陆却提示找不到action了 总之就是只能有一个生效,这个问题纠结了好几天了 具体报错为There is no action …… namespace[/]……这种
java web 项目问题,请大神帮帮忙
# 首次使用idea从svn当下elicpse项目导入,配置完成运行出现这样的错误。 HTTP Status 500 - Filter execution threw an exception type Exception report message Filter execution threw an exception description The server encountered an internal error that prevented it from fulfilling this request. exception javax.servlet.ServletException: Filter execution threw an exception com.rongyi.common.XssFilter.doFilter(XssFilter.java:23) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) root cause java.lang.ExceptionInInitializerError com.rongyi.filter.CheckSessionOutFilter.doFilter(CheckSessionOutFilter.java:42) com.rongyi.common.XssFilter.doFilter(XssFilter.java:23) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) root cause java.lang.StringIndexOutOfBoundsException: String index out of range: -1 java.lang.String.substring(String.java:1967) com.rongyi.common.utils.Constant.getpath(Constant.java:82) com.rongyi.common.utils.Constant.<clinit>(Constant.java:69) com.rongyi.filter.CheckSessionOutFilter.doFilter(CheckSessionOutFilter.java:42) com.rongyi.common.XssFilter.doFilter(XssFilter.java:23) 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/9.0.0.M9 logs. Apache Tomcat/9.0.0.M9 # web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <display-name></display-name> <!-- spring框架必须定义ContextLoaderListener,在启动Web容器时,自动装配Spring applicationContext.xml的配置信息 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <!-- 指定Spring上下文配置文件 --> <param-name>contextConfigLocation</param-name> <param-value>classpath*:applicationContext.xml</param-value> </context-param> <context-param> <param-name>spring.profiles.active</param-name> <param-value>production</param-value> </context-param> <servlet> <servlet-name>Dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <!-- 指定SpringMVC配置文件 --> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/springmvc.xml</param-value> </init-param> </servlet> <servlet-mapping> <!-- 指定请求的后缀,可以随意写,这里用.html作为请求后缀 --> <servlet-name>Dispatcher</servlet-name> <!-- <url-pattern>*.html</url-pattern> --> <url-pattern>/</url-pattern> </servlet-mapping> <!-- 编码格式为UTF-8 --> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 过滤sql注入,对传入的参数过滤特殊字符等 --> <filter> <filter-name>XssFilter</filter-name> <filter-class>com.rongyi.common.XssFilter</filter-class> </filter> <filter-mapping> <filter-name>XssFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 检查session是否过期filter --> <filter> <filter-name>CheckSessionFilter</filter-name> <filter-class> com.rongyi.filter.CheckSessionOutFilter </filter-class> </filter> <filter-mapping> <filter-name>CheckSessionFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> 请帮帮忙跪求。。。
myeclipse导入eclipse项目报错,依赖报错,
这个项目在别人eclipse那里部署成功,所以不是代码问题 报错信息: Error creating bean with name 'attachmentController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.jeefw.service.sys.AttachmentService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, mappedName=, description=, name=, type=class java.lang.Object, lookup=, authenticationType=CONTAINER)} 配置文件内容: ``` <context:annotation-config /> <context:component-scan base-package="com.jeefw.controller.sys,com.jeefw.dao.sys,com.jeefw.model.sys,com.jeefw.service.sys" /> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="com.mysql.jdbc.Driver" /> <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/jeefw?useUnicode=true&amp;characterEncoding=utf-8" /> <property name="user" value="root" /> <property name="password" value="123456" /> <!-- SQL Server数据库配置 --> <!-- <property name="driverClass" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" /> <property name="jdbcUrl" value="jdbc:sqlserver://localhost:1433;DatabaseName=jeefw" /> <property name="user" value="sa" /> <property name="password" value="123456" /> --> <!-- Oracle数据库配置 --> <!-- <property name="driverClass" value="oracle.jdbc.driver.OracleDriver" /> <property name="jdbcUrl" value="jdbc:oracle:thin:@127.0.0.1:1521:orcl" /> <property name="user" value="SYSTEM" /> <property name="password" value="SkyNet888999" /> --> <property name="acquireIncrement" value="3" /> <property name="idleConnectionTestPeriod" value="120" /> <property name="initialPoolSize" value="3" /> <property name="minPoolSize" value="3" /> <property name="maxPoolSize" value="15" /> <property name="numHelperThreads" value="3" /> <property name="preferredTestQuery" value="select 1" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop> <!-- SQL Server的Dialect方言配置 --> <!-- <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop> --> <!-- Oracle的Dialect方言配置 --> <!-- <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop> --> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.use_outer_join">true</prop> <prop key="hibernate.jdbc.fetch_size">30</prop> <prop key="hibernate.jdbc.batch_size">30</prop> <prop key="hibernate.jdbc.batch_versioned_data">true</prop> <prop key="hibernate.cache.use_second_level_cache">true</prop> <prop key="hibernate.cache.use_query_cache">true</prop> <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.EhCacheProvider</prop> <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory</prop> <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="javax.persistence.validation.mode">none</prop> <!-- 此注释里代码只跟全文检索有关,如需全文检索功能,放开注释,然后找到本文件的第87行和web.xml的第15行放开注释,重启应用服务器即可。可配置,不影响框架使用。苹果Mac电脑需要修改hibernate.search.default.indexBase参数。 --> <!-- <prop key="hibernate.search.default.directory_provider">filesystem</prop> <prop key="hibernate.search.default.indexBase">D:/JeefwLuceneIndexes</prop> <prop key="hibernate.search.default.refresh">1800</prop> <prop key="hibernate.search.default.indexwriter.max_merge_docs">100</prop> <prop key="hibernate.search.default.indexwriter.ram_buffer_size">64</prop> <prop key="hibernate.search.default.optimizer.operation_limit.max">1000</prop> <prop key="hibernate.search.default.optimizer.transaction_limit.max">100</prop> --> </props> </property> <property name="dataSource" ref="dataSource" /> <property name="packagesToScan"> <list> <value>com.jeefw.model</value> </list> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <tx:annotation-driven transaction-manager="transactionManager" /> <!-- 此注释里代码的作用是应用服务器每次启动都生成索引。在SystemInitListener里执行。可配置,不影响框架使用。 --> <!-- <bean id="informationService" class="com.jeefw.service.sys.impl.InformationServiceImpl" /> --> <bean id="indexingInformationJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject" ref="informationServiceImpl" /> <property name="targetMethod" value="indexingInformation" /> </bean> <!-- 每天凌晨2点执行定时任务,生成索引。 --> <bean id="indexingInformationJobTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean"> <property name="jobDetail" ref="indexingInformationJob" /> <property name="cronExpression" value="0 0 2 * * ?" /> </bean> <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false"> <property name="triggers"> <list> <ref bean="indexingInformationJobTrigger" /> </list> </property> </bean> <bean id="updateUserPwdLogicBean" class="com.app.logic.UpdateUserPwdLogicServer" /> <!-- 配置业务逻辑池 --> <bean id="logicExecuteWorkerEnginBean" class="com.app.logic.LogicExecuteWorkerEngine"> <property name="requestBeanTrans"> <map> <entry key="1302"> <value>com.app.bean.UpdateUserPwdRequestBean</value> </entry> </map> </property> <property name="logicPool"> <map> <entry key="1302"> <ref bean="updateUserPwdLogicBean" /> </entry> </map> </property> </bean> <!-- 配置接口传输操作协议对象 --> <bean id="transmissionBean" class="com.app.logic.Transmission"> </bean> ``` 数据源配置的密码我填的是错的密码,它不报数据库的错,却报这个错 换过tomcat的版本,也没用 我部署这个项目是通过在myeclipse里面新建一个web项目,然后把要用的文件夹一个一个copy过来的,配置文件和jar包也是,整个项目的配置我只改动了数据源的密码
有偿求助,新手上路,jsp跳转servlet出现404错误,求大佬帮助,有偿求助
![图片说明](https://img-ask.csdn.net/upload/201909/22/1569142924_2258.png)显示错误的页面。 jsp代码 <%@ page contentType="text/html;charset=UTF-8" language="java" %> <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"/> <meta http-equiv="X-UA-Compatible" content="IE=edge"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <title>首页</title> <!-- 1. 导入CSS的全局样式 --> <link href="css/bootstrap.min.css" rel="stylesheet"> <!-- 2. jQuery导入,建议使用1.9以上的版本 --> <script src="js/jquery-2.1.0.min.js"></script> <!-- 3. 导入bootstrap的js文件 --> <script src="js/bootstrap.min.js"></script> <script type="text/javascript"> </script> </head> <body> <div>${user.name},欢迎您</div> <div align="center"> <a href="${pageContext.request.contextPath}/userListServlet" style="text-decoration:none;font-size:33px">查询所有用户信息 </a> </div> </body> </html> servlet代码 package cn.itcast.web.servlet; import cn.itcast.domain.User; import cn.itcast.service.UserService; import cn.itcast.service.impl.UserServiceImpl; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.List; @WebServlet(name = "userListServlet") public class UserListServlet extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //1.调用UserService完成查询 UserService service = new UserServiceImpl(); List<User> users = service.findAll(); //2.将list存入request域 request.setAttribute("users",users); //3.转发到list.jsp request.getRequestDispatcher("/list.jsp").forward(request,response); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { }![图片说明](https://img-ask.csdn.net/upload/201909/22/1569143210_312516.png)![图片说明](https://img-ask.csdn.net/upload/201909/22/1569143252_580759.png) } web3.0以上应该不用配置web.xml文件,是自动配置的吧
Invalid bound statement (not found):但是代码上该配置都做了配置,以前也都是能正常运行的
这是pom的配置文件 ``` <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> </resource> <resource> <directory>src/main/resources</directory> </resource> </resources> ``` ``` /** *用户验证 */ List<HUser> userValidate(HUser user); ``` ``` <select id="userValidate" parameterType="com.ruanwei.pojo.HUser" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from H_USER where username = #{username} and password = #{password} </select> ``` 这是报错 ``` Servlet.service() for servlet [SpringMVC] in context with path [] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ruanwei.mapper.HUserMapper.userValidate] with root cause org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ruanwei.mapper.HUserMapper.userValidate at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:189) at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:43) at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:58) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:51) at com.sun.proxy.$Proxy29.userValidate(Unknown Source) at com.ruanwei.service.UserService.userValidate(UserService.java:75) at com.ruanwei.controller.UserController.userValidate(UserController.java:54) 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.invoke(InvocableHandlerMethod.java:215) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:690) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863) at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at com.ruanwei.web.filter.RequestResponseContextHolderFilter.doFilter(RequestResponseContextHolderFilter.java:29) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:444) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1137) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2579) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2568) 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) ``` 本来没有任何问题,但是给一小段代码加上打桩就出现这个问题了。另外这个项目是从myeclipse上导入到idea上的,本来也是有大大小小的一些问题
SSH整合过程中的报错ClassNotFoundException
错误提示如下: ``` 严重: Error configuring application listener of class org.apache.catalina.deploy.ApplicationListener@13159f1 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:527) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:509) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:137) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4854) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434) 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:633) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1113) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1671) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 八月 28, 2016 1:16:35 下午 org.apache.catalina.core.StandardContext listenerStart ``` 代码结构: ![图片说明](https://img-ask.csdn.net/upload/201608/28/1472361536_418080.png) web.xml配置: ``` <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>0828testOa</display-name> <!-- 监听器 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring/applicationContext.xml</param-value> </context-param> <!-- 过滤器 --> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> ``` 报的是:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener 我百度了一下,上面说的是缺少jar包,我也导入spring-web的jar包,另外也尝试了一下tomcat6 和7,都是报这个错误,醉了。
Eclipse编辑web.xml很卡
使用Eclipse {Version: 2018-12 (4.10.0)} 编辑 web.xml保存会很卡 ```xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> <display-name>ABC</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> </web-app> ``` 将XSD文件导入一样卡 ![图片说明](https://img-ask.csdn.net/upload/201901/01/1546334351_60964.png) 有什么方法可以解决这个问题吗?
新手求助!在MyEclipse导入Struts框架搭建的项目出现404错误!
HTTP Status 404 - /16/WebRoot/admin_index.jsp -------------------------------------------------------------------------------- type Status report message /16/WebRoot/admin_index.jsp description The requested resource is not available. -------------------------------------------------------------------------------- Apache Tomcat/7.0.63 struts.xml的配置文件如下: <?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> <package name="wyLogistics" extends="struts-default"> <action name="admin_*" class="com.webtier.AdminAction" method="{1}"> <result name="success">/admin_{1}.jsp</result> <result name="input">/admin_{1}.jsp</result> </action> <action name="car_*" class="com.webtier.CarAction" method="{1}"> <result name="success">/car_{1}.jsp</result> <result name="input">/car_{1}.jsp</result> <result name="operationSuccess" type="redirect">car_queryCarList.action</result> </action> <action name="customer_*" class="com.webtier.CustomerAction" method="{1}"> <result name="success">/customer_{1}.jsp</result> <result name="input">customer_queryCustomerList.action</result> <result name="operationSuccess1" type="redirect">customer_queryCustomerList.action</result> </action> <action name="goods_*" class="com.webtier.GoodsAction" method="{1}"> <result name="success">/goods_{1}.jsp</result> <result name="deleteSuccess" type="redirect">goods_queryGoodsList.action</result> </action> </package> </struts> web.xml的配置文件: <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> 一部分AdminAction的代码: public class AdminAction extends AdminForm { private static AdminDao adminDao = null; static{ adminDao=new AdminDao(); } // 对登录用户的表单验证是否为空 public void validateIndex() { if (null == admin_user || admin_user.equals("")) { this.addFieldError("admin_user", "| 请您输入用户名"); } if (null == admin_password || admin_password.equals("")) { this.addFieldError("admin_password", "| 请您输入密码"); } } // 对登录用户的表单验证 public String index() { String query_password = adminDao.getAdminPassword(admin_user); if (query_password.equals("")) { this.addActionError("| 该用户名不存在"); return INPUT; } if (!query_password.equals(admin_password)) { this.addActionError("| 您输入的密码有误,请重新输入"); return INPUT; } session.put("admin_user", admin_user); return SUCCESS; } // 对修改管理员密码表单验证是否为空 public void validateUpdatePassword() { if (null == admin_password || admin_password.equals("")) { this.addFieldError("admin_password", "请输入原密码"); } if (null == admin_repassword1 || admin_repassword1.equals("")) { this.addFieldError("admin_repassword1", "请输入新密码"); } if (null == admin_repassword2 || admin_repassword2.equals("")) { this.addFieldError("admin_repassword2", "请输入密码确认"); } if (!admin_repassword1.equals(admin_repassword2)) { this.addActionError("您输入两次密码不相同,请重新输入!!!"); } } public String updatePassword() { String query_password = adminDao.getAdminPassword(admin_user); if (!admin_password.equals(query_password)) { this.addFieldError("admin_password", "您输入的原密码有误,请重新输入"); } String sql = "update tb_admin set admin_password='" + admin_repassword1 + "' where admin_user='" + admin_user + "'"; if (!adminDao.operationAdmin(sql)) { this.addActionError("修改密码失败!!!"); return INPUT; } else { request.setAttribute("editPassword", "您修改密码成功,请您重新登录!!!"); return SUCCESS; } } } 第一次提问,希望大神们多多指教!小弟也会虚心受教。
springMVC无法进入controller的问题
springmvc一直无法进入controller导入404的问题 下帖配置文件: springmvc ``` <?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:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd "> <mvc:annotation-driven/> <!-- 自动扫描该包,使SpringMVC认为包下用了@controller注解的类是控制器 --> <context:component-scan base-package="com.controller" /> <context:component-scan base-package="com.impl" /> invengo.warehouse.service.impl" /> <!--避免IE执行AJAX时,返回JSON出现下载文件 --> <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> </list> </property> </bean> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <ref bean="mappingJacksonHttpMessageConverter" /> <!-- JSON转换器 --> </list> </property> </bean> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <!-- <property name="prefix" value="/WEB-INF/jsp/" /> --> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <!-- 默认编码 --> <property name="defaultEncoding" value="utf-8" /> <!-- 文件大小最大值 --> <property name="maxUploadSize" value="10485760000" /> <!-- 内存中的最大值 --> <property name="maxInMemorySize" value="40960" /> </bean> <context:annotation-config/> <mvc:resources location="/static/" mapping="/static/**"></mvc:resources> <!-- <mvc:resources location="" mapping=""/> --> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename"> <value>message</value> </property> <property name="defaultEncoding"> <value>UTF-8</value> </property> </bean> <!-- 日期全局转换配置 --> <bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean"> <property name="converters"> <list> <bean class="com.lava.springmvc.DateConverter" /> </list> </property> </bean> </beans> ``` web.xml ``` <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <!-- Spring和mybatis的配置文件 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext-*.xml</param-value> </context-param> <!-- 使用ContextLoaderListener保证启动时加载Spring --> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <servlet> <servlet-name>CXFServlet</servlet-name> <servlet-class> org.apache.cxf.transport.servlet.CXFServlet </servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>CXFServlet</servlet-name> <url-pattern>/ws/*</url-pattern> </servlet-mapping> <!-- 编码过滤器 --> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <async-supported>true</async-supported> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 防止Spring内存溢出监听器 --> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <!-- Spring MVC servlet --> <servlet> <servlet-name>SpringMVC</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:/WEB-INF/applicationContext-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> <async-supported>true</async-supported> </servlet> <servlet-mapping> <servlet-name>SpringMVC</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>/WEB-INF/jsp/login.jsp</welcome-file> </welcome-file-list> <session-config> <session-timeout>30</session-timeout> </session-config> </web-app> ``` 部分代码 ``` @Service("userService") public class UserServiceImpl implements IUserService{ ..... } ``` ``` @RestController public class LoginController { @RequestMapping("captcha.jpg") public void captcha(HttpServletResponse response)throws ServletException,IOException{ ...... } } ```
java编程中使用solrj,数据传递过程中出了问题,请帮忙看看到底是哪里出了问题并告诉我一下原因
## 使用tomcat7,myeclipse2017 C1,JDK 1.7,maven 3.2.3,solr 4.10.2 ## 通过浏览器访问http://search.taotao.com/search.html?q=tcl ,进入controller后, ## 错误信息: ![图片说明](https://img-ask.csdn.net/upload/201708/05/1501924252_501906.jpg) ![报错1](https://img-ask.csdn.net/upload/201708/05/1501924263_876276.jpg) ## controller: ![图片说明](https://img-ask.csdn.net/upload/201708/05/1501924317_113467.jpg) ## service: ![图片说明](https://img-ask.csdn.net/upload/201708/05/1501924345_921561.jpg) ![图片说明](https://img-ask.csdn.net/upload/201708/05/1501924354_916923.jpg) ## pojo:![图片说明](https://img-ask.csdn.net/upload/201708/05/1501924384_588215.jpg) ## solr中的schema.xml中的cid ![图片说明](https://img-ask.csdn.net/upload/201708/05/1501924421_73630.jpg) ## solr中cid的属性: ![图片说明](https://img-ask.csdn.net/upload/201708/05/1501924453_371269.jpg) ## 自己debug后发现映射过程中出问题的地方: ![图片说明](https://img-ask.csdn.net/upload/201708/05/1501924524_329295.jpg) ## 对queryResponse进行查看: ![图片说明](https://img-ask.csdn.net/upload/201708/05/1501924546_987631.jpg) ## 发现确实取到值了并贴出: ![图片说明](https://img-ask.csdn.net/upload/201708/05/1501924571_697979.jpg) ## 说一下程序中的数据来源吧,mysql中是直接导入的几千条数据 ![这是表的结构](https://img-ask.csdn.net/upload/201708/05/1501922858_408822.jpg) ## 然后用solrj将表中的数据导入到solr服务器中 的代码: ``` public class DataImportTest { private HttpSolrServer httpSolrServer; private static final ObjectMapper MAPPER = new ObjectMapper(); @Before public void setUp() throws Exception { // 在url中指定core名称:taotao //"http://solr.taotao.com/#/taotao"--界面操作 String url = "http://solr.taotao.com/taotao";//服务地址 HttpSolrServer httpSolrServer = new HttpSolrServer(url); //定义solr的server httpSolrServer.setParser(new XMLResponseParser()); // 设置响应解析器 httpSolrServer.setMaxRetries(1); // 设置重试次数,推荐设置为1 httpSolrServer.setConnectionTimeout(500); // 建立连接的最长时间 this.httpSolrServer = httpSolrServer; } @Test public void testData() throws Exception{ String url = "http://manage.taotao.com/rest/item?page={page}&rows=100"; int page = 1; int pageSize=0; do { String u = StringUtils.replace(url, "{page}", ""+page); String jsonData =doGet(u); JsonNode jsonNode = MAPPER.readTree(jsonData); String rowsStr = jsonNode.get("rows").toString(); List<Item> items=MAPPER.readValue(rowsStr, MAPPER.getTypeFactory().constructCollectionType(List.class, Item.class)); pageSize=items.size(); httpSolrServer.addBeans(items); this.httpSolrServer.commit(); page++; } while (pageSize == 100); } private String doGet(String url) throws Exception{ // 创建Httpclient对象 CloseableHttpClient httpclient = HttpClients.createDefault(); // 创建http GET请求 HttpGet httpGet = new HttpGet(url); CloseableHttpResponse response = null; try { // 执行请求 response = httpclient.execute(httpGet); // 判断返回状态是否为200 if (response.getStatusLine().getStatusCode() == 200) { return EntityUtils.toString(response.getEntity(), "UTF-8"); } } finally { if (response != null) { response.close(); } httpclient.close(); } return null; } } ``` ## 然后就是出了文章开头报的错误。 ![图片说明](https://img-ask.csdn.net/upload/201708/05/1501923430_422663.jpg) ## 在后续的编程过程中,我发现将item中的cid改为Integer,可以解决这个报错。 ## ## 但是通过后台新增的数据,查询就会报错,报的错为 ![报错2](https://img-ask.csdn.net/upload/201708/05/1501923241_176200.jpg) ## 与之前报的错(文章第一张图中的报错)刚好相反。但是将Item类中的cid改为Long型,那么查询新增数据(自己添加的数据)就没问题,查询导入的数据则报文章开头帖子中的错。 ## 这样,我的分析是导入的数据可能存在问题,是否是导入过程中将本来为long型的cid转为了Integer类型? ## ## 但是我确实不知道在哪个地方出错了,麻烦懂的大神帮忙给看看,并告之我详情,十分之感谢~需要什么地方的代码请跟我说,谢谢
ssh2整合,myeclipse10、2015CI都能运行,但2015会报错,怎回事?
SSH2整合,在MyEclipse10布署运行的时候没问题,但把项目导入到MyEclipse2015 CI时就把这个错误,貌似在MyEclipse2015 CI上整合SSH2都会报这个错,但项目都能运行,这是怎么回事? org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/context/CurrentSessionContext at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) 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: org/hibernate/context/CurrentSessionContext at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2476) at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:857) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1282) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1164) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:591) at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) ... 21 more Caused by: java.lang.ClassNotFoundException: org.hibernate.context.CurrentSessionContext at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1313) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1164) ... 32 more **applicationContext.xml** ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns:context="http://www.springframework.org/schema/context" xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"> </property> <property name="url" value="jdbc:mysql://127.0.0.1:3306/mydb?useUnicode=true&amp;amp;characterEncoding=UTF-8"> </property> <property name="username" value="root"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> </props> </property> <property name="mappingResources"> <list> <value>org/ssh/po/User.hbm.xml</value> </list> </property> </bean> <context:component-scan base-package="org.ssh" /> </beans> ```
写javaee项目中关于Baseservlet的一个问题
最近在写一个javaee项目,用到了多个servlet,发现这样很麻烦,然后模仿网上的代码,写了一个通用的servlet类--Baseservlet类并打包成jar包然后导入到类中,但是在运行时发生了错误,代码如下: Baseservlet类: ``` public class BaseServlet extends HttpServlet { public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=UTF-8"); String methodname=request.getParameter("method"); Method method=null; try { method = this.getClass().getMethod(methodname, HttpServletRequest.class, HttpServletResponse.class); } catch (Exception e) { throw new RuntimeException("您要调用的方法:" + methodname + "它不存在!", e); } try { String result=(String) method.invoke(this,request,response); if(result != null && !result.trim().isEmpty()) { int index = result.indexOf(":");//获取第一个冒号的位置 if(index == -1) {//如果没有冒号,使用转发 request.getRequestDispatcher(result).forward(request, response); } else {//如果存在冒号 String start = result.substring(0, index);//分割出前缀 String path = result.substring(index + 1);//分割出路径 if(start.equals("f")) {//前缀为f表示转发 request.getRequestDispatcher(path).forward(request, response); } else if(start.equals("r")) {//前缀为r表示重定向 response.sendRedirect(request.getContextPath() + path); } } } } catch (Exception e) { throw new RuntimeException(e); } } } ``` customerservlet类: ``` public class customerServlet extends BaseServlet { customerService cs=new customerService(); public String add(HttpServletRequest request,HttpServletResponse response) throws InstantiationException, IllegalAccessException, InvocationTargetException{ customer cus=Commenutils.toBean(request.getParameterMap(),customer.class ); cs.add(cus); request.setAttribute("msg","添加成功"); return "/msg.jsp"; } } ``` xml文件: ``` <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>webstudent</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>customerServlet</servlet-name> <servlet-class>com.customer.servlet.customerServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>customerServlet</servlet-name> <url-pattern>/customerServlet</url-pattern> </servlet-mapping> ``` 异常情况: ``` 严重: Servlet.service() for servlet [customerServlet] in context with path [/webstudent] threw exception java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at Servlet.BaseServlet.service(BaseServlet.java:45) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474) ``` 看异常好像是路径有问题,但不知道怎么改,希望大家能指导一下,谢谢
刚学习JSF,出现java.lang.ClassNotFoundException的异常
<p> </p> <pre name="code" class="web.xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;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"&gt; &lt;servlet&gt; &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt; &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt; &lt;load-on-startup&gt;0&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt; &lt;url-pattern&gt;*.faces&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;welcome-file-list&gt; &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; &lt;/web-app&gt; </pre> <p> 而且lib 也导入这些依赖包</p> <p><br><img src="http://dl.iteye.com/upload/attachment/0079/2244/98bef91e-2269-30e7-b458-66f4e95a4b88.jpg" alt=""></p> <p>但项目运行的时候都会出现下面的异常,包括复制别人的项目</p> <p> </p> <p>异常如下:<br>java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet</p> <p> <span style="white-space: pre;"> </span>at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)</p> <p><span style="white-space: pre;"> </span>at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)</p> <p><span style="white-space: pre;"> </span>at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:525)</p> <p><span style="white-space: pre;"> </span>at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:507)</p> <p><span style="white-space: pre;"> </span>at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:124)</p> <p><span style="white-space: pre;"> </span>at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1136)</p> <p><span style="white-space: pre;"> </span>at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)</p> <p><span style="white-space: pre;"> </span>at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5015)</p> <p><span style="white-space: pre;"> </span>at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5302)</p> <p><span style="white-space: pre;"> </span>at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)</p> <p><span style="white-space: pre;"> </span>at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:897)</p> <p><span style="white-space: pre;"> </span>at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:873)</p> <p><span style="white-space: pre;"> </span>at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)</p> <p><span style="white-space: pre;"> </span>at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1095)</p> <p><span style="white-space: pre;"> </span>at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1617)</p> <p><span style="white-space: pre;"> </span>at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)</p> <p><span style="white-space: pre;"> </span>at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)</p> <p><span style="white-space: pre;"> </span>at java.util.concurrent.FutureTask.run(FutureTask.java:138)</p> <p><span style="white-space: pre;"> </span>at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)</p> <p><span style="white-space: pre;"> </span>at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)</p> <p><span style="white-space: pre;"> </span>at java.lang.Thread.run(Thread.java:619)</p> <p> </p>
html文件能加载,但是css,js文件加载失败。
问题是:我直接在本地文件中找到那个html文件,用浏览器打开没有半点问题,但是我用 tomcat容器部署后,在浏览器地址栏用localhost:8080+应用名什么的访问的时候, 浏览器中只加载了那个html文件中的一些字、div什么的,外部导入的css,js文件都不显示,打开浏览器的控制台上各种资源找不到,404,用了ssm框架。html文件等是网上下的模板。 求大神指导!!! 贴代码贴代码:web.xml的配置 <welcome-file-list> <welcome-file>index.shop</welcome-file> </welcome-file-list> <servlet> <servlet-name>shop</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring/spring-*.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>shop</servlet-name> <url-pattern>*.shop</url-pattern> </servlet-mapping> </web-app> spring配置文件: <!-- 配置数据库连接参数及连接池 --> <bean id="dbcp" class="org.apache.commons.dbcp.BasicDataSource"> <property name="username" value="dbsnmp"/> <property name="password" value="Jindex"/> <property name="driverClassName" value="oracle.jdbc.OracleDriver"></property> <property name="url" value="jdbc:oracle:thin:@localhost:1521:Jindex"></property> </bean> <!-- 配置SqlSessionFactory处理类 --> <bean id="ssf" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dbcp"></property> <property name="mapperLocations" value="classpath:myBatis/*.xml"/> </bean> <!-- 配置mapper扫描 --> <bean id="mapperScanner" class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.chanct.shop.personal.dao"></property> </bean> <!-- 配置事物管理器,使申明式事务管理生效 --> <tx:annotation-driven transaction-manager="txManager"/> <!-- txManager 是一个Bean组件 --> <!-- MyBatis使用spring提供的DataSourceTransactionManager 使用DataSourceTransactionManager 必须设置属性dataSource --> <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dbcp"></property> </bean> 还有一个spring的配置文件里面是组件扫描,mvc注解扫描和视图解析器
请问这是什么原因,是关于servlet的包没有导入啥的吗?
在发布工程的时候com.bookonline.Filter.SetCharacterEncoding cannot be cast to javax.servlet.Filter ``` web.xml文件 <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <filter> <filter-name>Set Character Encoding</filter-name> <filter-class>com.bookonline.Filter.SetCharacterEncoding</filter-class> <init-param> <param-name>encoding</param-name> <param-value>GB2312</param-value> </init-param> <init-param> <param-name>ignore</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>Set Character Encoding</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app> SetCharacterEncoding.java文件 package com.bookonline.Filter; import javax.servlet.*; import java.io.IOException; import java.util.logging.Filter; import java.util.logging.LogRecord; public class SetCharacterEncoding implements Filter { private static String Encoding ; public void destroy() { // TODO Auto-generated method stub //System.out.println("---------exit filter"); } public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException { arg0.setCharacterEncoding(Encoding); //System.out.println("----------"+Encoding); arg2.doFilter(arg0, arg1); } public void init(FilterConfig arg0) throws ServletException { Encoding = arg0.getInitParameter("encoding"); //System.out.println("***************init filter"); } public boolean isLoggable(LogRecord record) { return false; } } ```
在elipse上导入hibernate框架出现问题
在一开始导入hibernate框架时,导入了hibernate全部的包和c3p0数据源的包,结果在包名上产生了冲突, eclipse无法自动正确导入,把鼠标移到 import org.hibernate*.;时出现 the package org.hibernate is accessible from more than one module:hibernate.c3p0, hibernate.commons.annotations,hibernate.core; 当我把有冲突的包移除几个暂时不用的时候,没有编译错误,但运行的时候出现java.lang.NoClassDefFoundError 具体如下 Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43) at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:87) at org.hibernate.cfg.Configuration.<init>(Configuration.java:123) at org.hibernate.cfg.Configuration.<init>(Configuration.java:118) at lee.NewsManager.main(NewsManager.java:30) Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source) at java.base/java.lang.ClassLoader.loadClass(Unknown Source) ... 5 more 具体代码如下: ```package lee; import org.hibernate.*; import org.hibernate.cfg.*; import org.hibernate.service.*; import org.hibernate.boot.registry.*; import org.crazyit.app.domain.New; public class NewsManager { public static void main(String[] args) throws Exception { // 实例化Configuration Configuration conf = new Configuration() // 不带参数的configure()方法默认加载hibernate.cfg.xml文件 // 如果传入abc.xml作为参数,则不再加载hibernate.cfg.xml,改为加载abc.xml .configure(); // 以Configuration实例创建SessionFactory实例 SessionFactory sf = conf.buildSessionFactory(); // 创建Session Session sess = sf.openSession(); // 开始事务 Transaction tx = sess.beginTransaction(); // 创建消息对象 New n = new New(); n.setContent( + "100"); sess.save(n); // 提交事务 tx.commit(); // 关闭Session sess.close(); sf.close(); } } package org.crazyit.app.domain; import java.util.ArrayList; import java.util.List; import javax.annotation.processing.Generated; import javax.persistence.CollectionTable; import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OrderColumn; import javax.persistence.Table; import javax.persistence.TableGenerator; @Entity @Table(name="news_inf") public class New { @TableGenerator(name="newsGen",table="NEWS_ID_GEN",pkColumnName="gen_key",valueColumnName="gen_value",pkColumnValue="new_id") @GeneratedValue(strategy=GenerationType.TABLE,generator="newsGen") private Integer id; // 消息标题 private String title; // 消息内容 private String content; @ElementCollection (targetClass=String.class) @CollectionTable(name="school_inf",joinColumns=@JoinColumn(name="person_id",nullable=false)) @Column(name="school_name") @OrderColumn(name="list_order") private List<String>schools=new ArrayList<>(); @ElementCollection (targetClass=Float.class) @CollectionTable(name="score_inf",joinColumns=@JoinColumn(name="person_id",nullable=false)) @MapKeyColumn(name="subject_name") @MapKeyClass(String.class) @Column(name="mark") // id的setter和getter方法 public void setId(Integer id) { this.id = id; } public Integer getId() { return this.id; } // title的setter和getter方法 public void setTitle(String title) { this.title = title; } public String getTitle() { return this.title; } @Generated(GenerationTime.ALWAYS) @Column(name="full_content") private String fullContent; // content的setter和getter方法 public void setContent(String content) { this.content = content; } public String getContent() { return this.content; } } 配置文件<?xml version="1.0" encoding="GBK"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- 指定连接数据库所用的驱动 --> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <!-- 指定连接数据库的url,其中hibernate是本应用连接的数据库名 --> <property name="connection.url">jdbc:mysql://localhost/hibernate?useSSL=true</property> <!-- 指定连接数据库的用户名 --> <property name="connection.username">root</property> <!-- 指定连接数据库的密码 --> <property name="connection.password">ak474247152919</property> <!-- 指定连接池里最大连接数 --> <property name="hibernate.c3p0.max_size">20</property> <!-- 指定连接池里最小连接数 --> <property name="hibernate.c3p0.min_size">1</property> <!-- 指定连接池里连接的超时时长 --> <property name="hibernate.c3p0.timeout">5000</property> <!-- 指定连接池里最大缓存多少个Statement对象 --> <property name="hibernate.c3p0.max_statements">100</property> <property name="hibernate.c3p0.idle_test_period">3000</property> <property name="hibernate.c3p0.acquire_increment">2</property> <property name="hibernate.c3p0.validate">true</property> <!-- 指定数据库方言 --> <property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property> <!-- 根据需要自动创建数据表 --> <property name="hbm2ddl.auto">update</property><!--①--> <!-- 显示Hibernate持久化操作所生成的SQL --> <property name="show_sql">true</property> <!-- 将SQL脚本进行格式化后再输出 --> <property name="hibernate.format_sql">true</property> <!-- 罗列所有持久化类的类名 --> <mapping class="org.crazyit.app.domain.News"/> </session-factory> </hibernate-configuration> ```
在中国程序员是青春饭吗?
今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...
【JSON解析】浅谈JSONObject的使用
简介 在程序开发过程中,在参数传递,函数返回值等方面,越来越多的使用JSON。JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,同时也易于机器解析和生成、易于理解、阅读和撰写,而且Json采用完全独立于语言的文本格式,这使得Json成为理想的数据交换语言。 JSON建构于两种结构: “名称/值”对的集合(A Collection of name/va...
《MySQL 性能优化》之理解 MySQL 体系结构
本文介绍 MySQL 的体系结构,包括物理结构、逻辑结构以及插件式存储引擎。
程序员请照顾好自己,周末病魔差点一套带走我。
程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。
一名大专同学的四个问题
【前言】   收到一封来信,赶上各种事情拖了几日,利用今天要放下工作的时机,做个回复。   2020年到了,就以这一封信,作为开年标志吧。 【正文】   您好,我是一名现在有很多困惑的大二学生。有一些问题想要向您请教。   先说一下我的基本情况,高考失利,不想复读,来到广州一所大专读计算机应用技术专业。学校是偏艺术类的,计算机专业没有实验室更不用说工作室了。而且学校的学风也不好。但我很想在计算机领...
复习一周,京东+百度一面,不小心都拿了Offer
京东和百度一面都问了啥,面试官百般刁难,可惜我全会。
Java 14 都快来了,为什么还有这么多人固守Java 8?
从Java 9开始,Java版本的发布就让人眼花缭乱了。每隔6个月,都会冒出一个新版本出来,Java 10 , Java 11, Java 12, Java 13, 到2020年3月份,...
达摩院十大科技趋势发布:2020 非同小可!
【CSDN编者按】1月2日,阿里巴巴发布《达摩院2020十大科技趋势》,十大科技趋势分别是:人工智能从感知智能向认知智能演进;计算存储一体化突破AI算力瓶颈;工业互联网的超融合;机器间大规模协作成为可能;模块化降低芯片设计门槛;规模化生产级区块链应用将走入大众;量子计算进入攻坚期;新材料推动半导体器件革新;保护数据隐私的AI技术将加速落地;云成为IT技术创新的中心 。 新的画卷,正在徐徐展开。...
轻松搭建基于 SpringBoot + Vue 的 Web 商城应用
首先介绍下在本文出现的几个比较重要的概念: 函数计算(Function Compute): 函数计算是一个事件驱动的服务,通过函数计算,用户无需管理服务器等运行情况,只需编写代码并上传。函数计算准备计算资源,并以弹性伸缩的方式运行用户代码,而用户只需根据实际代码运行所消耗的资源进行付费。Fun: Fun 是一个用于支持 Serverless 应用部署的工具,能帮助您便捷地管理函数计算、API ...
讲真,这两个IDE插件,可以让你写出质量杠杠的代码
周末躺在床上看《拯救大兵瑞恩》 周末在闲逛的时候,发现了两个优秀的 IDE 插件,据说可以提高代码的质量,我就安装了一下,试了试以后发现,确实很不错,就推荐给大家。 01、Alibaba Java 代码规范插件 《阿里巴巴 Java 开发手册》,相信大家都不会感到陌生,其 IDEA 插件的下载次数据说达到了 80 万次,我今天又贡献了一次。嘿嘿。 该项目的插件地址: https://github....
Python+OpenCV实时图像处理
目录 1、导入库文件 2、设计GUI 3、调用摄像头 4、实时图像处理 4.1、阈值二值化 4.2、边缘检测 4.3、轮廓检测 4.4、高斯滤波 4.5、色彩转换 4.6、调节对比度 5、退出系统 初学OpenCV图像处理的小伙伴肯定对什么高斯函数、滤波处理、阈值二值化等特性非常头疼,这里给各位分享一个小项目,可通过摄像头实时动态查看各类图像处理的特点,也可对各位调参、测试...
2020年一线城市程序员工资大调查
人才需求 一线城市共发布岗位38115个,招聘120827人。 其中 beijing 22805 guangzhou 25081 shanghai 39614 shenzhen 33327 工资分布 2020年中国一线城市程序员的平均工资为16285元,工资中位数为14583元,其中95%的人的工资位于5000到20000元之间。 和往年数据比较: yea...
为什么猝死的都是程序员,基本上不见产品经理猝死呢?
相信大家时不时听到程序员猝死的消息,但是基本上听不到产品经理猝死的消息,这是为什么呢? 我们先百度搜一下:程序员猝死,出现将近700多万条搜索结果: 搜索一下:产品经理猝死,只有400万条的搜索结果,从搜索结果数量上来看,程序员猝死的搜索结果就比产品经理猝死的搜索结果高了一倍,而且从下图可以看到,首页里面的五条搜索结果,其实只有两条才是符合条件。 所以程序员猝死的概率真的比产品经理大,并不是错...
害怕面试被问HashMap?这一篇就搞定了!
声明:本文以jdk1.8为主! 搞定HashMap 作为一个Java从业者,面试的时候肯定会被问到过HashMap,因为对于HashMap来说,可以说是Java集合中的精髓了,如果你觉得自己对它掌握的还不够好,我想今天这篇文章会非常适合你,至少,看了今天这篇文章,以后不怕面试被问HashMap了 其实在我学习HashMap的过程中,我个人觉得HashMap还是挺复杂的,如果真的想把它搞得明明白...
毕业5年,我问遍了身边的大佬,总结了他们的学习方法
我问了身边10个大佬,总结了他们的学习方法,原来成功都是有迹可循的。
python爬取百部电影数据,我分析出了一个残酷的真相
2019年就这么匆匆过去了,就在前几天国家电影局发布了2019年中国电影市场数据,数据显示去年总票房为642.66亿元,同比增长5.4%;国产电影总票房411.75亿元,同比增长8.65%,市场占比 64.07%;城市院线观影人次17.27亿,同比增长0.64%。 看上去似乎是一片大好对不对?不过作为一名严谨求实的数据分析师,我从官方数据中看出了一点端倪:国产票房增幅都已经高达8.65%了,为什...
推荐10个堪称神器的学习网站
每天都会收到很多读者的私信,问我:“二哥,有什么推荐的学习网站吗?最近很浮躁,手头的一些网站都看烦了,想看看二哥这里有什么新鲜货。” 今天一早做了个恶梦,梦到被老板辞退了。虽然说在我们公司,只有我辞退老板的份,没有老板辞退我这一说,但是还是被吓得 4 点多都起来了。(主要是因为我掌握着公司所有的核心源码,哈哈哈) 既然 4 点多起来,就得好好利用起来。于是我就挑选了 10 个堪称神器的学习网站,推...
这些软件太强了,Windows必装!尤其程序员!
Windows可谓是大多数人的生产力工具,集娱乐办公于一体,虽然在程序员这个群体中都说苹果是信仰,但是大部分不都是从Windows过来的,而且现在依然有很多的程序员用Windows。 所以,今天我就把我私藏的Windows必装的软件分享给大家,如果有一个你没有用过甚至没有听过,那你就赚了????,这可都是提升你幸福感的高效率生产力工具哦! 走起!???? NO、1 ScreenToGif 屏幕,摄像头和白板...
阿里面试,面试官没想到一个ArrayList,我都能跟他扯半小时
我是真的没想到,面试官会这样问我ArrayList。
曾经优秀的人,怎么就突然不优秀了。
职场上有很多辛酸事,很多合伙人出局的故事,很多技术骨干被裁员的故事。说来模板都类似,曾经是名校毕业,曾经是优秀员工,曾经被领导表扬,曾经业绩突出,然而突然有一天,因为种种原因,被裁员了,...
大学四年因为知道了这32个网站,我成了别人眼中的大神!
依稀记得,毕业那天,我们导员发给我毕业证的时候对我说“你可是咱们系的风云人物啊”,哎呀,别提当时多开心啦????,嗯,我们导员是所有导员中最帅的一个,真的???? 不过,导员说的是实话,很多人都叫我大神的,为啥,因为我知道这32个网站啊,你说强不强????,这次是绝对的干货,看好啦,走起来! PS:每个网站都是学计算机混互联网必须知道的,真的牛杯,我就不过多介绍了,大家自行探索,觉得没用的,尽管留言吐槽吧???? 社...
良心推荐,我珍藏的一些Chrome插件
上次搬家的时候,发了一个朋友圈,附带的照片中不小心暴露了自己的 Chrome 浏览器插件之多,于是就有小伙伴评论说分享一下我觉得还不错的浏览器插件。 我下面就把我日常工作和学习中经常用到的一些 Chrome 浏览器插件分享给大家,随便一个都能提高你的“生活品质”和工作效率。 Markdown Here Markdown Here 可以让你更愉快的写邮件,由于支持 Markdown 直接转电子邮...
看完这篇HTTP,跟面试官扯皮就没问题了
我是一名程序员,我的主要编程语言是 Java,我更是一名 Web 开发人员,所以我必须要了解 HTTP,所以本篇文章就来带你从 HTTP 入门到进阶,看完让你有一种恍然大悟、醍醐灌顶的感觉。 最初在有网络之前,我们的电脑都是单机的,单机系统是孤立的,我还记得 05 年前那会儿家里有个电脑,想打电脑游戏还得两个人在一个电脑上玩儿,及其不方便。我就想为什么家里人不让上网,我的同学 xxx 家里有网,每...
史上最全的IDEA快捷键总结
现在Idea成了主流开发工具,这篇博客对其使用的快捷键做了总结,希望对大家的开发工作有所帮助。
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
谁是华为扫地僧?
是的,华为也有扫地僧!2020年2月11-12日,“养在深闺人不知”的华为2012实验室扫地僧们,将在华为开发者大会2020(Cloud)上,和大家见面。到时,你可以和扫地僧们,吃一个洋...
AI 没让人类失业,搞 AI 的人先失业了
最近和几个 AI 领域的大佬闲聊 根据他们讲的消息和段子 改编出下面这个故事 如有雷同 都是巧合 1. 老王创业失败,被限制高消费 “这里写我跑路的消息实在太夸张了。” 王葱葱哼笑一下,把消息分享给群里。 阿杰也看了消息,笑了笑。在座几位也都笑了。 王葱葱是个有名的人物,21岁那年以全额奖学金进入 KMU 攻读人工智能博士,累计发表论文 40 余篇,个人技术博客更是成为深度学习领域内风向标。 ...
2020年,冯唐49岁:我给20、30岁IT职场年轻人的建议
点击“技术领导力”关注∆每天早上8:30推送 作者|Mr.K 编辑| Emma 来源|技术领导力(ID:jishulingdaoli) 前天的推文《冯唐:职场人35岁以后,方法论比经验重要》,收到了不少读者的反馈,觉得挺受启发。其实,冯唐写了不少关于职场方面的文章,都挺不错的。可惜大家只记住了“春风十里不如你”、“如何避免成为油腻腻的中年人”等不那么正经的文章。 本文整理了冯...
作为一名大学生,如何在B站上快乐的学习?
B站是个宝,谁用谁知道???? 作为一名大学生,你必须掌握的一项能力就是自学能力,很多看起来很牛X的人,你可以了解下,人家私底下一定是花大量的时间自学的,你可能会说,我也想学习啊,可是嘞,该学习啥嘞,不怕告诉你,互联网时代,最不缺的就是学习资源,最宝贵的是啥? 你可能会说是时间,不,不是时间,而是你的注意力,懂了吧! 那么,你说学习资源多,我咋不知道,那今天我就告诉你一个你必须知道的学习的地方,人称...
立即提问