web项目问题记录

来源:互联网 发布:网络匿名短信怎么发 编辑:程序博客网 时间:2024/04/24 20:19

1.出现java.lang.IllegalStateException异常,this web application instance has been stopped already.  Could not load java.net.BindException.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.在重新部署是发生,由于之前的线程未结束引起的,不影响功能。解决办法:修改tomcat目录下conf文件夹下的server.xml, 在<Host>标签添加子元素找到<Context>标签,把reloadble的属性值设为:reloadable="false"。

2.ajax,如果open选用get方式提交则send参数为null。如果open选用post提交则 xmlHttpRequest.open("POST","login.jsp",true);
                   xmlHttpRequest.setRequestHeder("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
                   xmlHttpRequest.send("user="+username+"&pwd="+password);

3.xmlHttp.open("GET","time.asp",true);第三个参数表示为异步处理

4.设置struts2的中文乱码解决filter

5.request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");容易忘记

6.ognl不一定要在struts2标签库里使用,使用和jsp一样的

7.struts拦截了request.getAttribute()方法并重新实现了它,如果HttpServletRequest没有我们要的属性,就从actionContext中找我们Put的对象 ,再没有就找valuestack中找,所有你后面把自定义 的test放到值栈中去了,就把本身action中的test属性盖了,el就只能找到这个hello了。 

8.在jsp页面使用ActionContext,<%@ page import="com.opensymphony.xwork2.util.*"%>

ValueStack vs = (ValueStack)request.getAttribute("struts.valueStack");
List<BigSort> l = (List)vs.findValue("bigSort");

9.ActionContext.getContext().getValueStack().set("bigSort", l);值放入ValueStack

10.hql分页查询Query query = session.createQuery("from Goods");
query.setFirstResult(num);
query.setMaxResults(count);
List<User> list = query.list();

11.外键查询时:Query query = session.createQuery("select count(*) from Goods where smallSort=?");
query.setParameter(0, smallSort);

long count = (Long) query.iterate().next();

12.在本地html页面与服务器进行ajax交互时会出现问题,只要把本地html页面通过服务器访问便可,jquery文件放在webroot目录下即可

13.为了在jsp中使用ognl可以借助struts2标签库<s:property value="list"/>

14.inverse为true的一方放弃管理关联关系

15.Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to get the default Bean Validation factory

数据连接池是在启动web服务器的时候才完成初始化的。当然连接不到数据库,spring中肯定有很多dao的操作,这些dao也都没有得到数据连接。
16.hql语句from User where userName=?
17.一个找了很久的错误:struts.xml文件中,导入别的struts-user.xml文件时注意里面的常量设置。
18.有时候明明什么都是对的,但是值就是为空,很有可能就是漏了get,set方法

0 0
原创粉丝点击