2014-01-18 128 views
0
  • ​​編輯</a>/<a href="/my/delete.htm?id=${history.serviceRequestId}">刪除</a>

應該是什麼上述URL.I我使用下列但它不工作春季安全URL模式匹配

<intercept-url pattern="/index*" access="permitAll" /> 
<intercept-url pattern="/register*" access="permitAll" /> 
<intercept-url pattern="/welcome*" access="hasRole('Techincian')" /> 
<intercept-url pattern="/my/*" access="hasRole('Techincian')" /> 
<intercept-url pattern="/my/*\?param=value" access="hasRole('Techincian')" /> 

+0

HREF = 「/我/ edit.htm?ServiceRequestId = $ {history.serviceRequestId}」>編輯/刪除 –

+0

+0

請告訴我正確的模式,將在上述情況下工作 –

回答

0

Spring表單。我想通過改變其領域status.some形式來控制。我想提交表單控制器,以接取的值更新由客戶提出的要求

h2>Update Request</h2> 
>form:form method="POST" action="/my/update.htm" commandName="servicehistory"> 
table align="center" border="0"> 

<tr><td>Request Id: </td> 
<td><form:input path="sr.ServiceRequestId" value="${sr.serviceRequestId}"></form:input>  < other fields.............. 
<tr><td><input type="submit" value="Save" /></td></tr> 

控制器訪問表單值並更新數據庫中的請求,但沒有發生.GUI顯示資源不可用。它沒有使用Spring Security。

@RequestMapping(value="/my/update.htm",method=RequestMethod.POST) 


public ModelAndView update(@ModelAttribute("servicehistory") @Valid ServiceHistories sh1,BindingResult result,ModelMap map) 

{ 

    Redirect it to another page after validating the form 
    return new ModelAndView(("redirect:/displaylist.htm")); 
} 

>Spring Security which implement security after matching url and user role 

< HTTP自動配置= 「真正的」 使用表達式= 「真」>

<intercept-url pattern="/admin/*" access="hasRole('Technician')" /> 
<intercept-url pattern="/my/**" access="hasRole('Techincian')" /> 
+0

嘗試在c:url中的表單中封裝動作url。 –

0

這是用來分配給compalint techincian JSP頁面。點擊提交後,它會給出數字格式例外。

<c:forEach items="${hlist}" var="history" varStatus="i"> 
<tr> 
<td><form:input path="requests[${i.index}].ServiceRequestId" value="${history.serviceRequestId }"></form:input></td> 

<td><form:input path="requests[${i.index}].Description" value="${history.description }"></form:input></td> 
<td><form:select multiple="false" path="requests[${i.index}].userto.UserId"> 
        <form:option value="NONE" label="--- Select ---" /> 

      <c:forEach items="${user}" var="u" varStatus="index">     
        <form:option label="${u.userName}" value="${u.userId}" /> 

        </c:forEach> 
        </form:select> 
</tr> 
</c:forEach> 
<tr><td> <input type="submit" value="Assign Technicians"></td></tr> 


>Controller : I am using Autopopulating list to access list coming from above form.But it gives Number format exception. But it is working for another scenario which is identical to this one. 
@ModelAttribute("requestForm") 
    public RequestForm getRequest() 
    { 
     RequestForm rf=new RequestForm(); 
     rf.setRequests(new AutoPopulatingList(ServiceRequests.class)); 
     return rf; 
    } 

    @RequestMapping(value="/admin/assigntech.htm",method=RequestMethod.POST) 
    public String assign(@ModelAttribute("requestForm") RequestForm requestForm,BindingResult result,ModelMap map) 
    { 
     List<ServiceRequests> sr=(List<ServiceRequests>)requestForm.getRequests(); 
     System.out.println(sr.size()); 
     System.out.println(sr.get(0).getUserto().getUserId()); 

     return "Welcome"; 
    } 
+0

請不要將問題發佈爲答案。 [編輯](http://stackoverflow.com/posts/21203804/edit)而不是你的帖子。 – GNKeshava

0

要像/我的/,你應該使用雙星因爲模式匹配遵循螞蟻標準匹配的文件夾下的一切**。