5月19日 JSP基础
1.ession内的存放的是对象的引用,所以修改内置对象后,不需要重新放置到session中
2.配置Context初始化参数
<Context-param>
<param-name></paran-name>
<param-value></param-value>
<Context-param>
this.getServletContext().getInitParameter(arg0);
-----------------------------------------------------------------------------------------------------------------
3.配置servlet初始化参数
<init-param>
<param-name></param-name>
<param-value></param-value>
</inti-param>
ServletConfig config=this.getServletConfig();
config.getParameter("");
-----------------------------------------------------------------------------------------------------------------
4配置文件 properties
格式: key=value 其中key不变 value是变化的
例如: #其中"#"为注释
文件 db.properties
username=秦焰培
password=peiaihua
最好放置到/WEB-INF/db.properties
读取属性文件的信息:
/在web应用中,getServletContext().getRealPath表示的
是web工程的根路径,
如:"C:\Program Files\apache-tomcat-6.0.18\webapps\TestURL"
String path=this.getServletContext().getRealPath("");
FileImputSream fi=new FileInputStream(path);
Properties pro=new Properties();
pro.load(fi);
pro.getProperty("key");
String realPath=this.getServletContext().getResourceAsStream("/WEB-INF/db.properties")
表示的也是从根路径开始加载文件:
-----------------------------------------------------------------------------------------------------------------
<!-- 该标签表示服务器启动时,自动创建servlet对象,而且数字越先优先级越高-->
<Load-on-startup>0,1,2,3,....</Load-on-srartup>
-----------------------------------------------------------------------------------------------------------------
servlet通信(communicate):
路径设置:
&n
相关文档:
在action里使用fileupload时,从reqeust得到的中文数据为乱码,尝试使用了
Java代码
1. DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setHeaderEnco ......
tomcat 默认使用的字符集是ISO-8859-1,不支持中文字符,所以在现实中文时需要转换字符和设置字符集。
server.mxl改为<Connector port="8080" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" /> ,添加代码转换字符String.getBytes("ISO-8859-1"),"UTF-8 ......
jsp中用javascript将中文Base64转码, Action中再用Base64解码
javascript中使用webtoolkit.base64.js,下载地址http://www.webtoolkit.info/djs/webtoolkit.base64.js
相关介绍 http://www.webtoolkit.info/javascript-base64.html
/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
*
**/ ......
<?xml version="1.0" encoding="UTF-8"?>
<%@ page contentType="text/html; charset=UTF-8" language="java" import="java.sql.*" errorPage="" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+pat ......
面的上便会弹出域控验证的
各位,上次在群中问到关于Jsp WEB系统登录与域控结合做用户验证的问题,现在已经解决,将解决办法与各位分享下:
解决方案:使用samba组织的开源项目jCIFS
项目首页:http://jcifs.samba.org/
参考资料:
使用jcifs.jar可以非常好实现,下载一个最新的jcifs.jar,放到WEB-INFlib下面,然后修改 ......