相关疑难解决方法(0)

Spring中的@ Component,@ Repository和@Service注释有什么区别?

@Component,@Repository@Service注释互换在Spring中,还是他们提供任何特殊的功能,除了作为一个符号设备?

换句话说,如果我有一个Service类并且我将注释更改@Service@Component,它仍然会以相同的方式运行吗?

或者注释是否也会影响类的行为和功能?

java spring annotations spring-mvc

1969
推荐指数
26
解决办法
86万
查看次数

Spring @RequestMapping

我在春天value = "/redirect/{id}"@RequestMapping注释中一直看到这种格拉姆.我一直想知道{id}这里有什么?这是某种Expression Language吗?

我看到的示例代码:

@RequestMapping( value = "/files/{id}", method = RequestMethod.GET )
public void getFile( @PathVariable( "id" )
String fileName, HttpServletResponse response )
{
    try
    {
         // get your file as InputStream
         InputStream is = new FileInputStream("/pathToFile/"+ fileName);
         // copy it to response's OutputStream
         IOUtils.copy( is, response.getOutputStream() );
         response.flushBuffer();
    }
    catch( IOException ex )
    {
         throw new RuntimeException( "IOError writing file to output stream" );
    }

}
Run Code Online (Sandbox Code Playgroud)

我的问题是{id}映射中的内容是什么,它与@PathVariable …

java spring spring-mvc request-mapping

9
推荐指数
1
解决办法
3万
查看次数

标签 统计

java ×2

spring ×2

spring-mvc ×2

annotations ×1

request-mapping ×1