java写配置文件代码,java配置教程
java配置文件怎么写?
参考java.util.Properties对象进行书写,另外可以在网上找一写辅助书写材料。
让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:主机域名、雅安服务器托管、营销软件、网站建设、句容网站维护、网站推广。
代码:
public static void main(String[] args) {
Properties p = new Properties();
p.setProperty("id", "user1");
p.setProperty("password", "123456");
try{
PrintStream stm = new PrintStream(new File("e:\test.properties"));
p.list(stm);
} catch (IOException e) {
e.printStackTrace();
}
}
java配置文件怎么写
web.xml配置如下:
?xml version="1.0" encoding="UTF-8" ?
- web-app version="2.4" xmlns="" xmlns:xsi="" xsi:schemaLocation=" "
- filter
filter-nameMyFilter/filter-name
filter-classgame.filter.MyFilter/filter-class
/filter
- filter-mapping
filter-nameMyFilter/filter-name
url-pattern/*/url-pattern
/filter-mapping
- welcome-file-list
welcome-fileindex.jsp/welcome-file
/welcome-file-list
/web-app
过滤器类如下:
package game.filter;
import java.io.IOException;
import javax.servlet.*;
public class MyFilter implements Filter {
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
chain.doFilter(request, response);
}
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
}
}
Java中的properties配置文件怎么写,代码
public static void main(String[] args) {
Properties p = new Properties();
p.setProperty("id", "user1");
p.setProperty("password", "123456");
try{
PrintStream stm = new PrintStream(new File("e:\test.properties"));
p.list(stm);
} catch (IOException e) {
e.printStackTrace();
}
}
文章题目:java写配置文件代码,java配置教程
分享网址:http://ybzwz.com/article/hcspgj.html