java 怎么添加可信网址_友好的网址映射问题-Java Spring

在回答我的问题之前,我曾不屑一顾.我现在可以访问我的其中一个春季应用程序.这是一个更好的配置.

注意对web.xml的更改,我很抱歉,但是映射到/ *会使调度程序解决您的所有请求.从某种意义上说,您创建了一个循环,您的初始映射将由调度程序转发到控制器,然后控制器将使用视图解析器来映射应转发请求的位置.映射到/ *导致视图解析器映射由调度程序处理.

更改为/会导致所有未映射的url由调度程序处理,因此您的初始映射由调度程序处理,调度程序将其发送到控制器,并且您的viewresolver创建的映射将映射到.??jsp,导致无法选择它由调度员处理.我很抱歉.

在web.xml

Spring3MVC

index.jsp

spring

org.springframework.web.servlet.DispatcherServlet

1

spring

/

spring-config.xml(必须更改组件扫描)

xmlns:beans="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:context="http://www.springframework.org/schema/context"

xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">

调节器

@RequestMapping(value={"/user/{id}"}, method=RequestMethod.GET)

public ModelAndView profileDisplay(

HttpServletRequest request,

HttpServletResponse response,

@RequestParam(value="id", required=false) String id

) throws UnknownHostException, MongoException {

ServiceSerlvet.appendSesssion(request);

//get search ALL users

BasicDBObject searchQuery = new BasicDBObject();

searchQuery.put("_id", new ObjectId(id));

List searchResponse = PersonController.searchUsers(searchQuery);

//System.out.println("response from search user method: "+searchResponse);

//This should display "WEB-INF/views/user.jsp" you may need to adjust.

return new ModelAndView("user", "people", searchResponse);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值