这可能与HTML?(Is this possible with HTML?)
我需要在网站中实施菜单卡。 我的顾客想要的是,它看起来就像在餐厅的卡片上。
是否可以在HTML文本中直接放置边框线,如下图所示(“Hauptgerichte”)? 如果是的话,我怎么能意识到这一点?
谢谢!
I need to implement a menucard in to a website. My customer wants, that it looks exactly like on the card in the restaurant.
Is it with HTML possible to put a border-line directly under the text like on the image below ("Hauptgerichte")? And if yes, how could I realize that?
Thanks!
原文:https://stackoverflow.com/questions/15960226
最满意答案
使用
standaloneSetup
您所做的只是执行特定控制器的设置。如果您不想配置整个应用程序上下文(使用
webAppContextSetup
而不是standaloneSetup
),可以通过将代码更改为:手动设置异常处理程序:@Before public void setup() throws IOException { MockitoAnnotations.initMocks(this); mockMvc = MockMvcBuilders.standaloneSetup(controller).setHandlerExceptionResolvers(new ExceptionHandlerExceptionResolver()).build(); } @Test public void test() throws Exception { mockMvc.perform(get("/verifyCert.controller").contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)).andExpect(status().isForbidden()); }
这是有效的,因为ExceptionHandlerExceptionResolver是Spring MVC用于处理基于
@ExceptionHandler
注释的异常的类查看我的一个较旧的相关答案,其中涵盖了一个更加困难的案例(在包含
@ExceptionHandler
的类上使用@ControllerAdvice
)。When using
standaloneSetup
all you are doing is performing the setup for the specific controller.If you don't want to configure the whole application context (which you would do with
webAppContextSetup
instead ofstandaloneSetup
), you can manually setup the exception handler by changing your code to:@Before public void setup() throws IOException { MockitoAnnotations.initMocks(this); mockMvc = MockMvcBuilders.standaloneSetup(controller).setHandlerExceptionResolvers(new ExceptionHandlerExceptionResolver()).build(); } @Test public void test() throws Exception { mockMvc.perform(get("/verifyCert.controller").contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)).andExpect(status().isForbidden()); }
This works because ExceptionHandlerExceptionResolver is the class that Spring MVC uses to handle exceptions based on the
@ExceptionHandler
annotationCheck out one of my older relevant answers that covers an ever more difficult case (the use of
@ControllerAdvice
on a class that contains@ExceptionHandler
).
相关问答
更多-
@exceptionhandler怎么使用[2021-09-03]
exception handler 异常处理; 异常处理程序; 异常处理例程 Secondly, all errors or unexpected warnings really should be handled by theexception handler. 其次,所有错误或意想不到的警告实际上应该由异常处理程序来处理。 -
您需要确定Spring的响应媒体类型应该如何确定。 这可以通过几种方式完成: 路径扩展(例如/image.jpg) 网址参数(例如?格式= jpg) HTTP Accept头(例如Accept:image / jpg) 默认情况下,Spring查看扩展而不是Accept头。 如果您实现扩展WebMvcConfigurerAdapter的@Configuration类,则可以更改此行为。 在那里你可以重写configureContentNegotiation(ContentNegotiationConfigu ...
-
添加一个中断点并不是真正的单元测试,实际上根本不是测试。 你可以称它为检查,但没有检查驱动开发这样的事情。 总之,单元测试的新手经常会发现这个问题,他们想测试私有或本地值让它成为一个变量或方法。 当我开始TDD时,我自己实际上已经相当分阶段了。 但事情是,在单元测试中,目的是对特定功能和所有可能的结果进行黑盒测试。 那个黑匣子里面发生的事情不是你关心的,也不需要单元测试它。 如果你想测试一个中间值,那么你的方法可能太长,应该分解成两个或更多可测试的小方法。 如果它不能完成,那么你不应该担心测试它们。 如果这 ...
-
谢谢大家的意见。 让我试着根据评论回答我的问题。 这是新的测试: public void testProperties() { assertThat(Helper.properties(), is(notNullValue())); } 我将简单地测试以确保该方法不返回空值。 如果方法返回非null值,则它将是Properties的实例。 这意味着无需测试方法是否返回Properties的实例。 Thanks all for your comments. Let me try to answer ...
-
Spring:RESTful控制器和错误处理帮助了我,我的问题是缺少这个: @Component public class AnnotatedExceptionResolver extends AnnotationMethodHandlerExceptionResolver{ public AnnotatedExceptionResolver() { setOrder(HIGHEST_PRECEDENCE); } } Spring: RESTful controllers and erro ...
-
使用standaloneSetup您所做的只是执行特定控制器的设置。 如果您不想配置整个应用程序上下文(使用webAppContextSetup而不是standaloneSetup ),可以通过将代码更改为:手动设置异常处理程序: @Before public void setup() throws IOException { MockitoAnnotations.initMocks(this); mockMvc = MockMvcBuilders.standaloneSetup(c ...
-
如何填充$ exceptionHandler的'cause'参数?(How do I populate the 'cause' parameter of $exceptionHandler?)[2023-08-03]
默认情况下,所有$exceptionHandler都使用给定参数登录到控制台: function $ExceptionHandlerProvider() { this.$get = ['$log', function($log) { return function(exception, cause) { // .apply means delegate the arguments $log.error.apply($log, arguments); // just del ... -
为了单元测试这个自定义的异常处理程序,创建sut / mut所需的依赖关系,并运行测试来验证预期的行为。 这是一个简单的例子,让你开始。 [TestClass] public class CustomExcpetionhandlerUnitTests { [TestMethod] public void ShouldHandleException() { //Arrange var sut = new CustomExceptionHandler(); ...
-
再次抛出异常,由DefaultHandlerExceptionResolver处理,以响应web.xml中定义的错误页面; 它不会调用控制器的相同异常处理程序。 @ExceptionHandler(Exception.class) public ModelAndView generateException(Exception ex) throws Exception{ if(condition) { return new ModelAndView("myError.jsp"); ...
-
哎呀,如果你的JNI崩溃了JVM,那么从junit开始测试肯定会很困难。 例如,你不能为SIGSEGV连接一个信号处理程序,JVM就会死掉。 如果是我,我会稍微更改一下并创建一个简单的Java类,其中Main调用崩溃的本机代码,在我的junit测试中,我将执行一个运行该包装类的Java运行时的新实例运行#EXEC。 然后,您可以等待生成的进程完成并检查其返回代码 - 如果它不为零,则执行时出现问题。 Ouch, if your JNI is crashing the JVM, then that's cer ...