JSP中获取当前绝对路径
错误:
String realPath = " http:// " + request.getServerName() + " : " + request.getServerPort() + request.getContextPath();
String realPath = " http:// " + request.getServerName() + " : " + request.getServerPort() + request.getServletPath();
正确:
String realPath = " http:// " + request.getServerName() + " : " + request.getServerPort() + request.getContextPath() + request.getServletPath().substring( 0 ,request.getServletPath().lastIndexOf( " / " ) + 1 );
如果想连带获取页面的名称时则去掉最后的substring即可.
相关文档:
在sql2000中创建存储过程:
--求两数之和
create proc up_sum @a int ,@b int ,@result int output
as
select @result= @a+@b
调用方法:
...
CallableStatement cstmt=con.prepareCall("exec up_sum ?,?,?");
cstmt.registerOutParameter(3,java.sql.Types.INTEGER);
&nb ......
修改了css 样式文件后,重新浏览该jsp页面,发现新修改的样式没有生效。总以为是项目缓存所引起的,于是清理所有项目,重新构建项目。不行。执行server 的 publish 还是不行。用window 的搜索功能发现除了 WebContent 目录有该 css 文件外,.metadata\.plugins\org.eclipse.wst.server.core\tmp1\webapps\ 目录下也存在该 c ......
上网看了好多,就这一篇解决了我的问题,现转,我的项目用的是MVC架构,有统一的控制器,转向不同的Action,上网看了好多,大部分是说加入request.setCharacterEncoding("utf-8");但是经过我的试验,这只有在利用JSP处理表单传输数据时才可用,在我的东西中无法解决,后来发现还是用FilterChain好,呵呵,重点还是在request ......