我希望有自定义404错误页面.我在类路径中有速度,但我不想使用速度视图解析器下面是我的代码
@EnableAutoConfiguration(exclude={VelocityAutoConfiguration.class})
@ComponentScan
public class Application {
Properties props = new Properties();
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
我无法将所有404重定向到资源目录中的某些html.
请协助
PS如果我使用velocityresolver并且在模板目录中有error.vm,它可以工作.
谢谢你的问候
你能解释一下为什么下面的工作方式确实如此.在我看来,java类型系统很难推断出R的类型
public class Test {
interface Parser<A,R>{
R parse(A a);
}
static class ResponseParser implements Parser<String,Integer>{
public Integer parse(String s) {
return Integer.parseInt(s) + 1;
}
}
interface Function<A,R>{
R with(A a);
}
public static <A,R,P extends Parser<A,R>> Function<P,R> getResult(final A res){
return new Function<P, R>() {
public R with(P parser) {
return parser.parse(res);
}
};
}
public static void main(String [] args){
Function<Parser<String,Integer>, Integer> func = getResult("1");
//this works
func.with(new ResponseParser());
// why this does not work
getResult("1").with(new ResponseParser()); …Run Code Online (Sandbox Code Playgroud) 下面的代码给出了这一行中多个标记的错误 - 递归值factWithTailRec需要类型 - 找到隐式转换:i => int2bigIn
@tailrec
val factWithTailRec = (i:Int, acc:BigInt) => if(i == 0) 1 else factWithTailRec(i-1, i * acc)
Run Code Online (Sandbox Code Playgroud)
可以请建议我如何防止它.要求是将val分配给递归函数
两个问候方法都一样
object test {
def greet = { println("hi")} //> greet: => Unit
def greet1(f: => Unit)= {println("hi")} //> greet1: (f: => Unit)Unit
}
Run Code Online (Sandbox Code Playgroud)
根据我的理解greet是一个函数,它不接受任何参数并返回Unit和参数按名称调用.而greet1是需要函数返回单位,也可以通过名字为它的参数调用的函数.很困惑,任何人都可以善解释这种差异.