我的第一个问题 - 是否可以在不使用数字证书的情况下使用https?我的第二个问题 - 我在我的网络应用程序中保护了几页.所以添加了以下内容
<security-constraint>
<web-resource-collection>
......
</web-resource-collection>
<auth-constraint>
......
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
Run Code Online (Sandbox Code Playgroud)
我尝试运行应用程序,并且没有加载ssl的页面.所以我继续创建证书.在server.xml中添加了以下内容?
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150"
scheme="https"
secure="true"
keystoreFile="C:\Program Files\apache-tomcat-7.0.11-windows-x86\apache-tomcat-7.0.11\.keystore"
keystorePass="johneipe"
clientAuth="optional"
sslProtocol="TLS" />
Run Code Online (Sandbox Code Playgroud)
我仍然无法访问这些页面,也无法访问https:// localhost:8443.
是否可以在不修改基类和派生类的情况下调用基类函数?
class Employee {
public String getName() {
return "Employee";
}
public int getSalary() {
return 5000;
}
}
class Manager extends Employee {
public int getBonus() {
return 1000;
}
public int getSalary() {
return 6000;
}
}
class Test {
public static void main(String[] args) {
Employee em = new Manager();
System.out.println(em.getName());
// System.out.println(em.getBonus());
System.out.println(((Manager) em).getBonus());
System.out.println(em.getSalary());
}
}
Run Code Online (Sandbox Code Playgroud)
输出:员工1000 6000
如何在em对象上调用Employee的getSalary()方法?
我在为Django模板加载CSS时遇到问题.
我有以下设置:
STATIC_ROOT = ''
STATIC_URL = '/css/'
STATICFILES_DIRS = ("/css")
INSTALLED_APPS = (
'django.contrib.staticfiles',
)
Run Code Online (Sandbox Code Playgroud)
我需要同时使用static_url,也staticfiles_dirs?
urls.py是
urlpatterns = patterns('',
(r'^$',homefun),
)
Run Code Online (Sandbox Code Playgroud)
views.py是
def homefun(request):
return render_to_response('home.html')
Run Code Online (Sandbox Code Playgroud)
父模板是base.html,它加载了css.
<link rel="stylesheet" type="text/css" href="/css/style.css" />
Run Code Online (Sandbox Code Playgroud) 我需要将一个字典和一个对象传递给一个模板.所以,我这样做
rc = RequestContext(request, {'prob':prob}, {'result':result})
return render_to_response('subject/question.html', context_instance=rc)
Run Code Online (Sandbox Code Playgroud)
但是我收到了一个错误.
Traceback: File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs) File "E:\django-sample\proschools\..\proschools\subject\views.py" in eval_c
72. rc = RequestContext(request, {'prob':prob}, {'result':result}) File "C:\Python27\lib\site-packages\django\template\context.py" in __init__
173. self.update(processor(request))
Exception Type: TypeError at /practice/c/eval/
Exception Value: 'str' object is not callable
Run Code Online (Sandbox Code Playgroud) 我们在Tomcat 8上运行Solr.我们在不同的环境中遇到问题,localhost_access_log文件填满了服务器.这些文件由如下配置的server.xml中的Access Valve Log创建 -
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log"
suffix=".txt" pattern="%h %l %u %t "%r" %s %b" />
Run Code Online (Sandbox Code Playgroud)
根据我的阅读,Tomcat中没有OOTB方式来清理旧的日志文件.我可以实现什么来清理旧的访问日志文件?
如何为使用 java InputStream API 创建和写入的文件设置只读访问权限。
是否可以使用Predicate接口执行此操作.
我有一个客户端类,它使用MathUtility类提供的函数.无论Mathmatical操作是什么,它都应该只在MathUtility类中发生.
//in client
MathUtility.sum(listOfInts, (Integer i)->{return (i<3);});
//in utility
class MathUtility<T extends Number> {
public static <T extends Number> T sumWithCondition(List<T> numbers, Predicate<T> condition) {
return numbers.parallelStream()
.filter(condition)
.map(i -> i)
.reduce(0, T::sum); //compile time error
}
public static <T extends Number> T avgWithCondition(List<T> numbers, Predicate<T> condition) {
//another function
}
//lot many functions go here
}
Run Code Online (Sandbox Code Playgroud)
现在它失败了这个错误 - The method reduce(T, BinaryOperator<T>) in the type Stream<T> is not applicable for the arguments (int, T::sum)
注意:我不想为不同的Number类型编写sum函数
我在十进制数上尝试了二进制乘法技术.
算法:
要将两个十进制数x和y相乘,请将它们彼此相邻,如下例所示.然后重复以下步骤:将第一个数字除以2,向下舍入结果(即,如果数字为奇数则丢弃:5),并将第二个数字加倍.继续前进,直到第一个数字变为1.然后删除第一个数字为偶数的所有行,并将第二列中的剩余数据加起来.
11 13
5 26
2 52
1 104
........
143(回答)
码:
class Multiply
{
static int temp;
static int sum;
public static void main(String[] args)
{
int x = Integer.parseInt(args[0]);
int y = Integer.parseInt(args[1]);
int ans = multiply(x , y);
System.out.println(ans);
}
public static int multiply(int x, int y)
{
if(x==1)
{
System.out.println(x+" : "+y);
return y;
}
temp = multiply(x/2, y*2);
if(x%2==0)
{
System.out.println(x+" : "+y);
return temp;
}
else
{
System.out.println(x+" : "+y);
sum = …Run Code Online (Sandbox Code Playgroud) 我有这个代码用于BinaryTree创建和遍历
class Node
{
Integer data;
Node left;
Node right;
Node()
{
data = null;
left = null;
right = null;
}
}
class BinaryTree
{
Node head;
Scanner input = new Scanner(System.in);
BinaryTree()
{
head = null;
}
public void createNode(Node temp, Integer value)
{
Node newnode= new Node();
value = getData();
newnode.data = value;
temp = newnode;
if(head==null)
{
head = temp;
}
System.out.println("If left child exits for ("+value+") enter y else n");
if(input.next().charAt(0)=='y')
{
createNode(temp.left, value);
} …Run Code Online (Sandbox Code Playgroud) 我想检查一下如何实现自定义收集器.
说,我需要做一些
(1)对字母 - 频率图等词语的分析和(2)将2个结果组合成单个结果的能力.
class CharHistogram implements Collector<String, Map<Character, Integer>, Map<Character, Integer>> {
public static CharHistogram toCharHistogram(){
return new CharHistogram();
}
@Override
public Supplier<Map<Character, Integer>> supplier() {
SysOut.print("supplier invoked");
return HashMap::new;
}
@Override
public BiConsumer<Map<Character, Integer>, String> accumulator() {
SysOut.print("accumulator invoked");
return (map, val) -> {
SysOut.print(val +" processed");
char[] characters = val.toCharArray();
for (char character : characters) {
int count = 1;
if (map.containsKey(character)) {
count = map.get(character);
count++;
}
map.put(character, count);
}
};
}
@Override
public BinaryOperator<Map<Character, …Run Code Online (Sandbox Code Playgroud) java ×7
algorithm ×2
django ×2
java-8 ×2
lambda ×2
tomcat ×2
binary-tree ×1
collectors ×1
css ×1
django-views ×1
generics ×1
https ×1
inheritance ×1
inputstream ×1
java-ee ×1
logging ×1
polymorphism ×1
recursion ×1
ssl ×1